Two quick WPF tricks: Show tooltip on disabled control and accessibility for WPF button

13 באפריל 2008

2 תגובות

[This blog was migrated. You will not be able to comment here.
The new URL of this post is]

Question: When my control is disabled, it does not show any toolip, in spite of the fact, that it has one. What to do?

Answer: Use ToolTipService.ShowOnDisabled="True" attached property

Question: You wrote grate article about accessibility of WPF. How to use it with QTP/WinRunner (or any other visual test programs). However it works on lists and other items controls, but not on content controls. What to do?

Answer: It works as well. More, then this. It works also without “style" hack” in .NET 3.5. See yourself


Here the source code

<StackPanel Orientation="Vertical" DataContext="{StaticResource datas}">       
        <ListBox ItemsSource="{Binding}" ItemTemplate="{StaticResource t1}" ItemContainerStyle='{StaticResource stl}' IsSynchronizedWithCurrentItem='True'/>
        <Button Content="{Binding Path=Prop2}" ToolTip="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Content}"/>
        <Button Content="{Binding Path=Prop2}" ToolTipService.ShowOnDisabled="True" IsEnabled="False" ToolTip="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Content}"/>

It works. If you’re using 3.0 just set AutomationProperties.Name property by using setters in style as described in the article and this will work for you.

<Style x:Key="stl">
            <Setter Property="AutomationProperties.Name" Value="{Binding Prop2}"/>

Have a nice day

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

2 תגובות

  1. felix.koehler@tecdoc.net23 ביולי 2008 ב 11:36

    QTP and WPF

  2. Bummed21 בדצמבר 2008 ב 5:06

    I thought i found the answer to my problem alas the language the tooltip code is written in must be vb6 or some other ancient lingo thanks anyway