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

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

image

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}”/>
    </StackPanel>

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}”/>
        </Style>

Have a nice day

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • Live
  • Reddit
  • TwitThis
  • email
  • Slashdot
  • StumbleUpon

3 Responses to “Two quick WPF tricks: Show tooltip on disabled control and accessibility for WPF button”

  1. Bummed Says:

    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

  2. felix.koehler@tecdoc.net Says:

    QTP and WPF

  3. Michael Sync Says:

    Great.. Tip #1 helped me a lot.

Leave a Reply

Recommended

 


Sponsor


Partners

WPF Disciples
Dreamhost
Code Project
Switched to Better Place

Together