zoukankan      html  css  js  c++  java
  • 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.显示效果如下:

    完整样例

  • 相关阅读:
    Cannot attach the file *.mdf as database
    frameset frame 实例和用法 转
    remove element
    伸展树--java
    Remove Duplicates from Sorted Array
    merge two sorted lists
    valid parentheses
    Longest Common Prefix
    palindrome number(回文数)
    Two Sum
  • 原文地址:https://www.cnblogs.com/runningRain/p/13957662.html
Copyright © 2011-2022 走看看