Convert CheckBoxField to ToggleButton in Infragistics XamDataGrid

276 views Asked by At

I'm struggling with display CheckBoxField in Infragistics XamDataGrid as togglebutton. Everything seems to work fine, until i press those togglebutton - it is not refreshing corresponding value in viewmodel. On the other hand, when i change the bound value elsewhere in the system, ChecBoxField is refreshed. If someone had idea how to do it correct, it will make me happy.

My code:

[...]
    <UserControl.Resources>
        <ResourceDictionary>
[...]
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type igWpf:CellValuePresenter}">
                            <ToggleButton Content="{TemplateBinding Value, Converter={StaticResource Converter}}" IsChecked="{TemplateBinding Value}"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

[...]
        <igWpf:XamDataGrid DataSource="{Binding Oscillators}"  AutoFit="true" Grid.Column="1" HorizontalAlignment="Left"
                           GroupByAreaLocation="None"
                           IsNestedDataDisplayEnabled="False"
                           cal:Message.Attach="[Event AssigningFieldLayoutToItem] = [Action AssignFieldLayout($source)] ">
            <igWpf:XamDataGrid.FieldLayouts>
            <igWpf:FieldLayout>
                <igWpf:FieldLayout.Fields>
                    <igWpf:TextField IsReadOnly="True" Name="Name"></igWpf:TextField>
                    <igWpf:CheckBoxField Name="OnOff" Label="On/Off">
                        <igWpf:Field.Settings>
                                <igWpf:FieldSettings  CellValuePresenterStyle="{StaticResource ToggleButtonCellStyle}"></igWpf:FieldSettings>
                        </igWpf:Field.Settings>
                    </igWpf:CheckBoxField>
                    [...]
                 </igWpf:NumericField>
                </igWpf:FieldLayout.Fields>
            </igWpf:FieldLayout>
           </igWpf:XamDataGrid.FieldLayouts>
            [...]
        </igWpf:XamDataGrid>
1

There are 1 answers

0
Thaven On BEST ANSWER

ok, i got it. This is correct binding, working in both way:

                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type igWpf:CellValuePresenter}">
                        <ToggleButton Content="{TemplateBinding Value, Converter={StaticResource Converter}}"  IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"/>
                    </ControlTemplate>
                </Setter.Value>