基于列数据的 DataGrid 单元格工具提示

发布于 2024-10-03 16:48:18 字数 3167 浏览 4 评论 0原文

在我的应用程序中,我尝试实现工具提示,它将根据数据网格列的文本向我显示数据网格中的一些错误。例如,我有 4 列,其中包含用于输入一些数据的文本框,如果某些列中的数据不太符合规则,或者如果其中一些在最后 4 列上为空,我应该显示带有一些说明文本的工具提示。

<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>

有人知道最好的方法吗?

In my application, i have tried to implement tooltip wich will show me some errors in the datagrid based on the dataGrid Column's text. For sample I have 4 columns with text-boxes for entering some data and if data in the some column doesn't much the rule or if some of them are empty on the last 4th column i should show tooltip with some explanation text.

<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 anybody know best way to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文