Why DevExpress GridControl show empty tooltip?

2019-09-17 08:02发布

问题:

I create DevExpress GridControl. Here full code of GroupBox and GridControl, because i do not know why it shows empty tooltip. I try to make many changes at code, read DevExpress forum but it not work.

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

But, it is very strange , when i try to see tooltip: it shows empty string!

Here the image:

How to make so that the tooltip showed the same value, as in in a grid?

回答1:

Try to set the Tooltip property in the CellStyle of the column:

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