DataGrid dashboard based on column data

In my application, I tried to implement a tooltip that will show me some errors in a datagrid based on the text of the dataGrid column. For the sample, I have 4 columns with text fields for entering some data, and if the data in some column does not change the rule much, or if some of them are empty in the last 4th column, I should show a tooltip with some text explanation.

<WpfToolkit:DataGridTemplateColumn Width="0.02*" IsReadOnly="True">
          <WpfToolkit:DataGridTemplateColumn.CellStyle>
            <Style TargetType="{x:Type WpfToolkit:DataGridCell}" BasedOn="{StaticResource TransparentCellSelection}">
              <Style.Triggers>

                <DataTrigger Value="1">
                  <DataTrigger.Binding>
                    <MultiBinding Converter="{StaticResource DataGridRowToolTipConverter}">
                      <Binding Path="IsRequired" />
                      <Binding Path="InputColumns.Count" />
                      <Binding Path="HasDefaultValue" />
                      <Binding Path="HasOverwritingValue" />
                      <Binding Path="MappingType" />
                      <Binding Path="SourceColumnMappings" />
                      <Binding Path="ColumnStatus" />
                    </MultiBinding>
                  </DataTrigger.Binding>
                  <Setter Property="ToolTip" Value="Translation mapping is incomplete." />
                </DataTrigger>

                <DataTrigger Value="2">
                  <DataTrigger.Binding>
                    <MultiBinding Converter="{StaticResource DataGridRowToolTipConverter}">
                      <Binding Path="IsRequired" />
                      <Binding Path="InputColumns.Count"/>
                      <Binding Path="HasDefaultValue" />
                      <Binding Path="HasOverwritingValue" />
                      <Binding Path="MappingType" />
                      <Binding Path="SourceColumnMappings" />
                      <Binding Path="ColumnStatus" />
                    </MultiBinding>
                  </DataTrigger.Binding>
                  <Setter Property="ToolTip" Value="Overwriting Value overrides Mapping. Mapping and Default Value are ignored." />
                </DataTrigger>

                <DataTrigger Value="3">
                  <DataTrigger.Binding>
                    <MultiBinding Converter="{StaticResource DataGridRowToolTipConverter}">
                      <Binding Path="IsRequired" />
                      <Binding Path="InputColumns.Count" />
                      <Binding Path="HasDefaultValue" />
                      <Binding Path="HasOverwritingValue" />
                      <Binding Path="MappingType" />
                      <Binding Path="SourceColumnMappings" />
                      <Binding Path="ColumnStatus" />
                    </MultiBinding>
                  </DataTrigger.Binding>
                  <Setter Property="ToolTip" Value="Default Value cannot be set for empty Mapping. Please define Mapping or use Overwriting Value instead of Default Value." />
                </DataTrigger>

Does anyone know a better way to do this?

+3
source share

Source: https://habr.com/ru/post/1775818/


All Articles