WPF DevExpress GridColumn ComboBox 显示选择内容的 TooTip
实现显示当前选择的ComboBox中项的ToolTip信息;
1. 设置 GridColumn 的 CellTemplate 为 ComboBoxEdit , 然后自定义他的 ItemContainerStyle。
<dxg:GridColumn FieldName="Name"> <dxg:GridColumn.CellTemplate> <DataTemplate> <dxe:ComboBoxEdit Name="PART_Editor" DisplayMember="Name" ItemsSource="{Binding Path=ItemsSource, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dxg:GridControl}}" ToolTip="{Binding Path=SelectedItem, RelativeSource={RelativeSource Self}}"> <dxe:ComboBoxEdit.ItemContainerStyle> <Style TargetType="dxe:ComboBoxEditItem"> <Setter Property="ToolTip" Value="{Binding}"/> </Style> </dxe:ComboBoxEdit.ItemContainerStyle> </dxe:ComboBoxEdit> </DataTemplate> </dxg:GridColumn.CellTemplate> </dxg:GridColumn>
2. 设置 ItemContainerStyle 的显示样式
<Style TargetType="ToolTip"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <StackPanel DataContext="{Binding ., Converter={StaticResource con}}"> <TextBlock Text="{Binding Name}" /> <TextBlock Text="{Binding FirstValue}" /> <TextBlock Text="{Binding SecondValue}" /> <TextBlock Text="{Binding IsCompleted}" /> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style>
3.显示效果如下: