i have been created the new common class for ToolTip in Touchscreen. And i have a lot of the control and page for ToolTip. So i just want to using about this common class in XAML.
@ Common Class
public class CommonLayout : Window
{
Timer Timer { get; set; }
ToolTip toolTip { get; set; }
public CommonLayout(TextBlock control)
{
Timer = new Timer();
Timer.Interval = 3000;
Timer.Elapsed += OnTimerElapsed;
control.MouseLeave += OnMouseLeave;
control.MouseLeftButtonUp += OnMouseLeftButtonUp;
}
public void OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
CloseToolTip();
}
public void OnMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
toolTip = ((ToolTip)((TextBlock)sender).ToolTip);
toolTip.IsOpen = true;
Timer.Start();
}
private void CloseToolTip()
{
if (toolTip != null)
{
toolTip.IsOpen = false;
}
}
private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{
Timer.Stop();
Application.Current.Dispatcher.BeginInvoke((Action)CloseToolTip, DispatcherPriority.Send);
}
}
@XAML i want to binding for common ToolTip class about below 3 kind of TextBlock. and it have to using in other page also.
<StackPanel Margin="30">
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" TextWrapping="Wrap" Text="ToolTip Test"
ToolTipService.ShowOnDisabled="True" >
<TextBlock.ToolTip>
<ToolTip Placement="Mouse" Content="This is ToolTip Test." />
</TextBlock.ToolTip>
</TextBlock>
<TextBlock x:Name="textBlock1" HorizontalAlignment="Left" TextWrapping="Wrap" Text="ToolTip Test1"
ToolTipService.ShowOnDisabled="True" >
<TextBlock.ToolTip>
<ToolTip Placement="Mouse" Content="This is ToolTip Test." />
</TextBlock.ToolTip>
</TextBlock>
<TextBlock x:Name="textBlock2" HorizontalAlignment="Left" TextWrapping="Wrap" Text="ToolTip Test2"
ToolTipService.ShowOnDisabled="True" >
<TextBlock.ToolTip>
<ToolTip Placement="Mouse" Content="This is ToolTip Test." />
</TextBlock.ToolTip>
</TextBlock>
</StackPanel>