开发者

My IconverterClass changing values to all my columns

I have a table with different columns I am showing two in this code :

<DataGridTextColumn Header="Allocated" Binding="{Binding Allocated}" >
  <DataGridTextColumn.ElementStyle>
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="Background">
        <Setter.Value>
          <MultiBinding Converter="{StaticResource converter}">
            <Binding Path="Current_Phase" />
            <Binding Path="Status" />
          </MultiBinding>
        </Setter.Value>
      </Setter>
    </Style>
  </DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Op10}" Header="WIP OP10" >
  <DataGridTextColumn.ElementStyle>
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="Background">
        <Setter.Value>
          <MultiBinding Converter="{StaticResource converter}">
            <Binding Path="Current_开发者_如何学GoPhase" />
            <Binding Path="Status" />
          </MultiBinding>
        </Setter.Value>
      </Setter>
    </Style>
  </DataGridTextColumn.ElementStyle>
</DataGridTextColumn>

The problem I have My IConverterClass is returning a background colour and is putting green for both, but my current phase is "op30"(my parameters value) but still is changing the colour of column op10. I am totally lost, pls helppppp.

My converter Class

 object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {


     string type = values[0].ToString();
         string status = values[1].ToString();             

         if (type == "op10"  && status == "10")
         {
             return Brushes.Green;

         }
         else if ( type == "op30" && status == "30")
         {
             return Brushes.Green;
         }

        else
         {
             return DependencyProperty.UnsetValue;
         }           

   }

Please Helppp, I dont know what to do.


I don't understand your problem:
Your converter returns green for "op10" and "op30" and you bind that converter to both columns and therefore it changes both columns to green. If you don't want to change the column op10, remove the binding to the converter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜