I have developed a WPF sample project.
Here is the main Window's XAML markup :
<Window x:Class="ToolTipSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
WindowState="Maximized">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button Click="OnButtonClick">Show ToolTip</Button>
<StatusBar Grid.Row="2">
<StatusBarItem>
<TextBlock Text="TextBlock With ToolTip">
<TextBlock.ToolTip>
<ToolTip x:Name="m_toolTip">
ToolTip
</ToolTip>
</TextBlock.ToolTip>
</TextBlock>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>
Here is the main Window's code-behind without the using statements :
namespace ToolTipSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void OnButtonClick(object p_sender, RoutedEventArgs p_args)
{
m_toolTip.IsOpen = true;
}
}
}
I want to programmatically show the ToolTip when the Button is clicked.
I want the ToolTip to be shown above its TextBlock parent.
The ToolTip is automatically shown when the mouse cursor is over the TextBlock and during a constant amount of time C approximatively equal to 5 seconds.
I want the ToolTip to be shown during C when the Button is clicked.
My goals are not achieved in the current project.
The ToolTip is shown when the Button is clicked :
But :
- The ToolTip is too far from its TextBlock parent.
- The ToolTip is not automatically hidden
What do I have to do to achieve my goals ?
Any help will be greatly appreciated.