...">

Two-way XamDataGrid field binding

I have the following code inside XamDataGrid:

 <igDp:Field Name="IsBlackChecked"  Label="Black Image" />

The problem is that this is not a two-way binding. When I click the checkbox in the user interface, the value is not set.

I tried the following solution:

 <igWPF:Field Name="IsBlackChecked" Label="Black Image" Width="Auto"  >
    <igWPF:Field.Settings>
      <igWPF:FieldSettings AllowEdit="True">
        <igWPF:FieldSettings.EditorStyle>
          <Style TargetType="{x:Type igWPF:XamCheckEditor}" 
            BasedOn="{StaticResource {x:Type igWPF:XamCheckEditor}}" >                                                <Setter Property="IsChecked"                                                        Value="{Binding DataItem.IsBlackChecked, Mode=TwoWay}"/>
           </Style>
         </igWPF:FieldSettings.EditorStyle>
        <igWPF:FieldSettings.CellValuePresenterStyle>
       <Style TargetType="{x:Type igWPF:CellValuePresenter}">
         <Setter Property="Template">
          <Setter.Value>
           <ControlTemplate TargetType="{x:Type igWPF:CellValuePresenter}">
            <CheckBox IsChecked="{Binding DataItem.IsBlackChecked, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
           </ControlTemplate>
          </Setter.Value>
         </Setter>
        </Style>
       </igWPF:FieldSettings.CellValuePresenterStyle>
      </igWPF:FieldSettings>
     </igWPF:Field.Settings>
   </igWPF:Field>

This gives me a two-way snap, but it changes the style of the cell and the boundary lines go away,

How can I specify two-way binding in this field in the first parameters / restore border lines in the second?

+4
source share
1 answer
<igDp:Field Name="IsBlackChecked"  Label="Black Image" />

By default, these are two ways binding(you can check any data type). The real problems in your scenario could be

  • checkbox, CellvaluePresenter moues click event. , , checkbox, checkbox. ( .)
  • INotifyProertyChanged model class. , ( ) record, property ().

:

editorstyle, cellvaluepresenterstyle. editorstyle ( cellvaluepresentrer . , border cell, , , . )

editorstyle template/bindings, . , .

 <Style x:Key="PrevPolLocIDStyle" TargetType="{x:Type igEditors:XamTextEditor}" BasedOn="{StaticResource {x:Type igEditors:XamTextEditor}}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                    <ContentControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                    Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type igDP:CellValuePresenter}}, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                 Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type igDP:CellValuePresenter}}, Path=Background, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                               BorderThickness="0,0" >

                    </ContentControl>
                    <Ellipse Height="10" Width="10" VerticalAlignment="Center" HorizontalAlignment="Right" ToolTip="Single Sublocation" Margin="10,0,0,0" >
                    <Ellipse.Style>
                        <Style  TargetType="{x:Type Ellipse}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type igDP:DataRecordCellArea}}, Path=Record.DataItem.IsSingleInGroup}" Value="true">
                                    <Setter Property="Fill" Value="Blue"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type igDP:DataRecordCellArea}}, Path=Record.DataItem.IsSingleInGroup}" Value="false">
                                    <Setter Property="Fill" Value="Transparent"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Ellipse.Style>
                </Ellipse>
                </StackPanel>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

controltemplate XamTextEditor. fieldsetting editorstyle.

 <igDP:FieldSettings EditorStyle="{StaticResource PrevPolLocIDStyle}"> 

. CellvaluePresenter Template, . editorstyle , bool checkbox. , CellvaluePresenter editorstyle .

+1

All Articles