为什么 DevExpress GridControl 显示空工具提示?
Why DevExpress GridControl show empty tooltip?
我创建了 DevExpress GridControl。
这里是 GroupBox 和 GridControl 的完整代码,因为我不知道为什么它显示空的工具提示。
我尝试在代码上做很多更改,阅读 DevExpress 论坛但它不起作用。
<GroupBox Grid.Row="0">
<GroupBox.Header>
<TextBlock FontWeight="Bold"
Text="GroupBox"/>
</GroupBox.Header>
<Grid
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
>
<Grid.RowDefinitions>
<RowDefinition Height="*" ></RowDefinition>
</Grid.RowDefinitions>
<dxg:GridControl Grid.Row="0"
x:Name="grUsagePoint"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
dx:ThemeManager.ThemeName="Seven"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding Collection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding CurrentElement,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
>
<dxg:GridControl.View>
<!--region #RowCellMenuCustomization-->
<dxg:TableView x:Name="view" AutoWidth="True">
<dxg:TableView.RowCellMenuCustomizations>
<dxb:BarButtonItem Content="First"
ItemClick="CellDataItem_Link_ItemClick"
Glyph="First.png"
>
</dxb:BarButtonItem>
<dxb:BarButtonItem Content="Second"
ItemClick="CellDataItem_UnLink_ItemClick"
Glyph="Second.png"
>
</dxb:BarButtonItem>
<dxb:BarButtonItem Content="Third"
ItemClick="CellDataItem_Open_ItemClick"
Glyph="Third.png"
>
</dxb:BarButtonItem>
<dxb:BarItemSeparator />
<dxb:BarButtonItem Content="Something"
ItemClick="CellDataItem_FindInTree_ItemClick"
Glyph="Something.png"
>
</dxb:BarButtonItem>
</dxg:TableView.RowCellMenuCustomizations>
</dxg:TableView>
<!--endregion #RowCellMenuCustomization-->
</dxg:GridControl.View>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="First column"
AllowEditing="False"
Width="*"
HorizontalHeaderContentAlignment="Stretch"
AllowResizing="True"
Binding="{Binding First,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
></dxg:GridColumn>
<dxg:GridColumn Header="Second column"
AllowEditing="False"
MinWidth="80"
Width="Auto"
HorizontalHeaderContentAlignment="Stretch"
AllowResizing="True"
ToolTip="tooltip"
Binding="{Binding Second,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Second"
>
</dxg:GridColumn>
<dxg:GridColumn Header="Third column"
AllowEditing="False"
Visible="False"
Width="*"
HorizontalHeaderContentAlignment="Stretch"
AllowResizing="True"
ToolTip="tool tip"
Binding="{Binding Third,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Third"
>
</dxg:GridColumn>
<dxg:GridColumn Header="Fourth column
AllowEditing="False"
HorizontalHeaderContentAlignment="Center
FixedWidth="True"
AllowResizing="False"
Width="35"
ToolTip="tool tip"
Binding="{Binding Fourth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Header tooltip"
>
</dxg:GridColumn>
<dxg:GridColumn Header="fifth column"
AllowEditing="False"
HorizontalHeaderContentAlignment="Center"
FixedWidth="True"
AllowResizing="False"
Width="35"
ToolTip="tool tip"
Binding="{Binding Fifth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Header tooltip"
>
</dxg:GridColumn>
<dxg:GridColumn
Header="sixth column"
Binding="{Binding Sixth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
ToolTip="tool tip"
HorizontalHeaderContentAlignment="Stretch"
FixedWidth="False"
AllowEditing="False" AllowResizing="True" HeaderToolTip="Header tooltip"
></dxg:GridColumn>
<dxg:GridColumn
Header="Seventh column"
Binding="{Binding Seventh,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
AllowEditing="False"
ToolTip="tool tip"
HorizontalHeaderContentAlignment="Stretch"
Width="*"
AllowResizing="True"
HeaderToolTip="Header tooltip"
/>
</dxg:GridControl.Columns>
<dxg:GridControl.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
<MenuItem Header="First"
Command="{Binding FirstCommand}">
<MenuItem.Icon>
<Image Source="First.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Second"
Command="{Binding SecondCommand}">
<MenuItem.Icon>
<Image Source="Second.png" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Third"
Command="{Binding ThirdCommand}">
<MenuItem.Icon>
<Image Source="Third.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Fourth"
Command="{Binding FourthCommand}">
<MenuItem.Icon>
<Image Source="Fourth.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding OpenCommand}"/>
</dxg:GridControl.InputBindings>
</dxg:GridControl>
</Grid>
</GroupBox>
但是,很奇怪,当我尝试查看工具提示时:它显示空字符串!
这里是图片:
如何使工具提示显示与网格中相同的值?
尝试在CellStyle
列中设置Tooltip
属性:
<dxg:GridColumn Header="Fourth column"
AllowEditing="False"
HorizontalHeaderContentAlignment="Center"
FixedWidth="True"
AllowResizing="False"
Width="35"
Binding="{Binding Fourth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
<dxg:GridColumn.CellStyle>
<Style BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}" TargetType="dxg:GridCellContentPresenter">
<Setter Property="ToolTip" Value="tool tip"/>
</Style>
</dxg:GridColumn.CellStyle>
</dxg:GridColumn>
我创建了 DevExpress GridControl。 这里是 GroupBox 和 GridControl 的完整代码,因为我不知道为什么它显示空的工具提示。 我尝试在代码上做很多更改,阅读 DevExpress 论坛但它不起作用。
<GroupBox Grid.Row="0">
<GroupBox.Header>
<TextBlock FontWeight="Bold"
Text="GroupBox"/>
</GroupBox.Header>
<Grid
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
>
<Grid.RowDefinitions>
<RowDefinition Height="*" ></RowDefinition>
</Grid.RowDefinitions>
<dxg:GridControl Grid.Row="0"
x:Name="grUsagePoint"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
dx:ThemeManager.ThemeName="Seven"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding Collection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding CurrentElement,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
>
<dxg:GridControl.View>
<!--region #RowCellMenuCustomization-->
<dxg:TableView x:Name="view" AutoWidth="True">
<dxg:TableView.RowCellMenuCustomizations>
<dxb:BarButtonItem Content="First"
ItemClick="CellDataItem_Link_ItemClick"
Glyph="First.png"
>
</dxb:BarButtonItem>
<dxb:BarButtonItem Content="Second"
ItemClick="CellDataItem_UnLink_ItemClick"
Glyph="Second.png"
>
</dxb:BarButtonItem>
<dxb:BarButtonItem Content="Third"
ItemClick="CellDataItem_Open_ItemClick"
Glyph="Third.png"
>
</dxb:BarButtonItem>
<dxb:BarItemSeparator />
<dxb:BarButtonItem Content="Something"
ItemClick="CellDataItem_FindInTree_ItemClick"
Glyph="Something.png"
>
</dxb:BarButtonItem>
</dxg:TableView.RowCellMenuCustomizations>
</dxg:TableView>
<!--endregion #RowCellMenuCustomization-->
</dxg:GridControl.View>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="First column"
AllowEditing="False"
Width="*"
HorizontalHeaderContentAlignment="Stretch"
AllowResizing="True"
Binding="{Binding First,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
></dxg:GridColumn>
<dxg:GridColumn Header="Second column"
AllowEditing="False"
MinWidth="80"
Width="Auto"
HorizontalHeaderContentAlignment="Stretch"
AllowResizing="True"
ToolTip="tooltip"
Binding="{Binding Second,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Second"
>
</dxg:GridColumn>
<dxg:GridColumn Header="Third column"
AllowEditing="False"
Visible="False"
Width="*"
HorizontalHeaderContentAlignment="Stretch"
AllowResizing="True"
ToolTip="tool tip"
Binding="{Binding Third,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Third"
>
</dxg:GridColumn>
<dxg:GridColumn Header="Fourth column
AllowEditing="False"
HorizontalHeaderContentAlignment="Center
FixedWidth="True"
AllowResizing="False"
Width="35"
ToolTip="tool tip"
Binding="{Binding Fourth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Header tooltip"
>
</dxg:GridColumn>
<dxg:GridColumn Header="fifth column"
AllowEditing="False"
HorizontalHeaderContentAlignment="Center"
FixedWidth="True"
AllowResizing="False"
Width="35"
ToolTip="tool tip"
Binding="{Binding Fifth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" HeaderToolTip="Header tooltip"
>
</dxg:GridColumn>
<dxg:GridColumn
Header="sixth column"
Binding="{Binding Sixth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
ToolTip="tool tip"
HorizontalHeaderContentAlignment="Stretch"
FixedWidth="False"
AllowEditing="False" AllowResizing="True" HeaderToolTip="Header tooltip"
></dxg:GridColumn>
<dxg:GridColumn
Header="Seventh column"
Binding="{Binding Seventh,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
AllowEditing="False"
ToolTip="tool tip"
HorizontalHeaderContentAlignment="Stretch"
Width="*"
AllowResizing="True"
HeaderToolTip="Header tooltip"
/>
</dxg:GridControl.Columns>
<dxg:GridControl.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
<MenuItem Header="First"
Command="{Binding FirstCommand}">
<MenuItem.Icon>
<Image Source="First.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Second"
Command="{Binding SecondCommand}">
<MenuItem.Icon>
<Image Source="Second.png" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Header="Third"
Command="{Binding ThirdCommand}">
<MenuItem.Icon>
<Image Source="Third.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Fourth"
Command="{Binding FourthCommand}">
<MenuItem.Icon>
<Image Source="Fourth.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.InputBindings>
<MouseBinding MouseAction="LeftDoubleClick"
Command="{Binding OpenCommand}"/>
</dxg:GridControl.InputBindings>
</dxg:GridControl>
</Grid>
</GroupBox>
但是,很奇怪,当我尝试查看工具提示时:它显示空字符串!
这里是图片:
如何使工具提示显示与网格中相同的值?
尝试在CellStyle
列中设置Tooltip
属性:
<dxg:GridColumn Header="Fourth column"
AllowEditing="False"
HorizontalHeaderContentAlignment="Center"
FixedWidth="True"
AllowResizing="False"
Width="35"
Binding="{Binding Fourth,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
<dxg:GridColumn.CellStyle>
<Style BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=CellStyle}}" TargetType="dxg:GridCellContentPresenter">
<Setter Property="ToolTip" Value="tool tip"/>
</Style>
</dxg:GridColumn.CellStyle>
</dxg:GridColumn>