Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
325
A checkbox event occurs when a field group is dynamically added to the field layout.
posted

<Grid Grid.Row="2">
    <igDP:XamDataGrid x:Name="U_DataList"
                      BorderBrush="{StaticResource BorderColorBrush}"
                      IsGroupByAreaExpanded="False"
                      SelectedItemsChanged="U_SampleData_SelectedItemsChanged"
                      Style="{DynamicResource XamGridStyle}">
        <igDP:XamDataGrid.Resources>
            <Style TargetType="{x:Type igDP:DataRecordCellArea}">
                <Setter Property="Background" Value="{StaticResource BackColorWhiteBrush}" />
                <Setter Property="BackgroundAlternate" Value="{StaticResource BackColorDarkWhiteBrush}" />
            </Style>

            <Style TargetType="{x:Type igDP:CellValuePresenter}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=DataItem.IsChecked, Mode=TwoWay}" Value="True">
                        <Setter Property="Background" Value="{StaticResource LightBlueBrush}" />
                        <Setter Property="BorderBrush" Value="{StaticResource LightBlueBrush}" />
                        <Setter Property="BorderThickness" Value="0.3" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style BasedOn="{x:Null}" TargetType="{x:Type igDP:RecordSelector}">
                <Setter Property="Margin" Value="7,2,0,0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type igDP:RecordSelector}">
                            <CheckBox HorizontalAlignment="Center"
                                      VerticalAlignment="Center"
                                      IsChecked="{Binding Path=DataItem.IsChecked, Mode=TwoWay}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style BasedOn="{x:Null}" TargetType="{x:Type igDP:HeaderPrefixArea}">
                <Setter Property="Margin" Value="7,2,0,0" />
                <Setter Property="Visibility" Value="Visible" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type igDP:HeaderPrefixArea}">
                            <CheckBox HorizontalAlignment="Center"
                                      VerticalAlignment="Center"
                                      Checked="CheckBox_Checked"
                                      IsChecked="True"
                                      Unchecked="CheckBox_Checked" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </igDP:XamDataGrid.Resources>

        <igDP:XamDataGrid.FieldSettings>
            <igDP:FieldSettings AllowEdit="False" />
        </igDP:XamDataGrid.FieldSettings>

        <igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:FieldLayoutSettings AllowClipboardOperations="All"
                                      AutoFitMode="ExtendLastField"
                                      AutoGenerateFields="False"
                                      CopyFieldLabelsToClipboard="True"
                                      HighlightAlternateRecords="True" />
        </igDP:XamDataGrid.FieldLayoutSettings>

        <igDP:XamDataGrid.FieldLayouts>
            <igDP:FieldLayout x:Name="U_FieldLayout" >

                <!--#region Checkbox-->
                <igDP:Field Name="IsChecked"
                            Width="50"
                            HorizontalContentAlignment="Center"
                            VerticalContentAlignment="Center"
                            Visibility="Collapsed" />
                <!--#endregion-->



                <!--#region Color-->
                <igDP:TemplateField Name="Color"
                                    Width="60"
                                    HorizontalContentAlignment="Center"
                                    Label="Color"
                                    LabelTextAlignment="center">
                    <igDP:TemplateField.Settings>
                        <igDP:FieldSettings CellClickAction="SelectRecord" />
                    </igDP:TemplateField.Settings>
                    <igDP:TemplateField.DisplayTemplate>
                        <DataTemplate>
                            <Rectangle Width="40"
                                       Height="2"
                                       Fill="{Binding Path=(igEditors:TemplateEditor.Editor).Value, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorToBrush}}" />
                        </DataTemplate>
                    </igDP:TemplateField.DisplayTemplate>
                </igDP:TemplateField>
                <!--#endregion-->



                <!--#region Name-->
                <igDP:Field Name="Name"
                            Width="1*"
                            HorizontalContentAlignment="left"
                            Label="Name"
                            LabelTextAlignment="center">
                    <igDP:Field.Settings>
                        <igDP:FieldSettings CellClickAction="SelectRecord" />
                    </igDP:Field.Settings>
                </igDP:Field>
                <!--#endregion-->



                <!--#region AcquiredTime-->
                <igDP:Field Name="AcquiredTime"
                            Width="1*"
                            HorizontalContentAlignment="left"
                            Format="yyyyMMdd HH:mm:ss"
                            Label="Acquired time"
                            LabelTextAlignment="center">
                    <igDP:Field.Settings>
                        <igDP:FieldSettings CellClickAction="SelectRecord" />
                    </igDP:Field.Settings>
                </igDP:Field>
                <!--#endregion-->

            </igDP:FieldLayout>
        </igDP:XamDataGrid.FieldLayouts>
    </igDP:XamDataGrid>
</Grid>

public void AddProductField(string model_name, string product_name, string unit)
{
    FieldGroup group          = new FieldGroup();
    group.Label               = model_name;
    group.LabelTextAlignment  = System.Windows.TextAlignment.Center;
    group.LabelPresenterStyle = Application.Current.FindResource("GroupStyle") as Style;

    FieldSettings settings   = new FieldSettings();
    settings.CellClickAction = CellClickAction.SelectRecord;

    Field field              = new Field();
    field.Name               = "Value";
    field.Settings           = settings;
    field.Width              = new FieldLength(1, FieldLengthUnitType.Star);
    field.Label              = $"{product_name}\n[{unit}]";
    field.LabelTextAlignment = System.Windows.TextAlignment.Center;

    group.Children.Add(field);
    m_view.U_FieldLayout.FieldItems.Add(group);


    //this.m_view.CheckBox_Checked(null, null);
}

AddProductField is called under certain conditions to add a group, but the problem is that the checkbox defined as a style in HeaderPrefixArea is called.
The check event contains code that checks or unchecks all items in the data grid.
When inserting data into the data grid, the check box is checked and then entered into the data. However, after AddProductField is called, all data becomes unchecked.

Parents
No Data
Reply
  • 325
    Offline posted

    m_view.U_DataList.DataSource = probe.DataList;
    
    public class SpectrumDataListSt : INotifyPropertyChanged
    {
    public int No { get; set; }
    
    private bool _IsChecked = false;
    public bool IsChecked
    {
    get => this._IsChecked;
    set
    {
    if (this._IsChecked != value)
    {
    this._IsChecked = value;
    
    
    // [Model데이터 계산]
    {
    //ModelCommonMethod.GetConc(ModelCommonMethod.DATA_TYPE.ABS, )
    }
    
    
    OnPropertyChanged(nameof(IsChecked));
    }
    }
    }
    
    public Color Color { get; set; }
    public string Name { get; set; }
    public DateTime AcquiredTime { get; set; }
    public ObservableCollection<ProductDataListSt> ProductDataLists = new ObservableCollection<ProductDataListSt>();
    
    
    
    
    
    
    public event PropertyChangedEventHandler PropertyChanged;
    protected virtual void OnPropertyChanged(string name)
    {
    this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
    }

    I have one more question. In the AddProductField function, field.Name = "Value"; I'm binding it, but in fact
    It must be bound to Value in ProductDataLists. Will there be binding in this structure?

Children