基于列数据的 DataGrid 单元格工具提示
在我的应用程序中,我尝试实现工具提示,它将根据数据网格列的文本向我显示数据网格中的一些错误。例如,我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论