[PropertyGrid] How to show tooltip of header?

Grids for WPF Forum

The latest build of this product (v24.1.2) was released 2 months ago, which was before this thread was created.
Posted 10 days ago by Yuki
Version: 24.1.2
Avatar

Hello,

We are using PropertyGrid as the following.

When change column width smaller, header text will be ommited. (ex. "Na...")

We would like to show tooltip of header text when it is ommited.

Would you please tell me how to do it?

Xaml:

<Window
    x:Class="PropertyGridSample.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:grids="http://schemas.actiprosoftware.com/winfx/xaml/grids"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="MainWindow"
    Width="800"
    Height="450"
    mc:Ignorable="d">
    <Grid>
        <grids:PropertyGrid
            x:Name="MyPropertyGrid"
            AreColumnHeadersVisible="True"
            DataObject="{Binding RelativeSource={RelativeSource AncestorType=Window}}" />
    </Grid>
</Window>

Code behind:

namespace PropertyGridSample
{
    using ActiproSoftware.Windows.Controls.Grids;
    using System.Windows;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            foreach (var column in MyPropertyGrid.Columns.OfType<TreeListViewColumn>())
            {
                column.MinWidth = 20;
                column.MaxWidth = double.NaN;
            }
        }
    }
}

Comments (1)

Answer - Posted 10 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

You could set the column.HeaderTemplate to a DataTemplate resource whose value is something like this:

<DataTemplate x:Key="ColumnHeaderTemplate">
	<shared:AdvancedTextBlock x:Name="textBlock" Margin="5,3" Text="{Binding}"
		TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
</DataTemplate>

Out of the box, the TreeListViewColumnHeader control's Template uses a standard WPF ContentPresenter, so a string column name "Content" value will resolve to a standard WPF TextBlock.  But our AdvancedTextBlock has built-in logic to show a tooltip when text doesn't fit, thereby forcing a template that uses AdvancedTextBlock will allow that feature.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.