I've got a problem which has been tormenting me for the last couple of days. I have a grid (Infragistics) to which I've applied a CellPresenterStyle which will change the contents of the cell to a ToggleButton if
- The cell is in the currently selected row, and
- The databound field is contained in a collection in my ViewModel
The last piece in the puzzle is to bind the IsChecked property of the ToggleButton to a specific boolean property on my ViewModel. For instance, if the Templated field is "Counterparty", I want the ToggleButton.IsChecked binding to be to "UseQueryCounterparty".
Any ideas?? Current Style is below.
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="ToggleButtonStyle">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<!-- make sure the row is selected -->
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.IsSelected}" Value="True" />
<Condition Value="True">
<Condition.Binding>
<!-- Only change the rendering if the field is one of the break fields -->
<MultiBinding Converter="{StaticResource IsInCollection}" >
<Binding RelativeSource="{RelativeSource Self}" Path="Field.Name" />
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type vw:ResolveBreakView}}" Path="DataContext.BreakFields" />
</MultiBinding>
</Condition.Binding>
</Condition>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Template">
<Setter.Value>
<ToggleButton
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetValueForQueryCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Field.Name}"
>
<ToggleButton.IsChecked>
<Binding Path="???" /> <!-- This is the line that doesn't fly -->
</ToggleButton.IsChecked>
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" />
</ToggleButton>
</Setter.Value>
</Setter>
<!--<Setter Property="Background" Value="Red" />-->
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>