I am trying to add a ToolTip
on my TextBlock
. After some research this is how I added it on UWP
xaml:
<ListView x:Name="flyList" BorderThickness="0" ItemsSource="{Binding}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Border BorderThickness="0,0,0,1" BorderBrush="#FF7C7C7C">
<TextBlock Text="{Binding}" Tapped="TextBlock_Tapped">
<ToolTipService.ToolTip>
<ToolTip Name="tip1" Content="Click to copy signal to clipboard."/>
</ToolTipService.ToolTip>
</TextBlock>
</Border>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
How can I set the ToolTip
's content? Or better how can I even access it?
I want to access it on TextBlock
's tapped event.
private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e)
{
/*
var send = sender as TextBlock;
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
dataPackage.SetText(send.Text);
Clipboard.SetContent(dataPackage);
*/
}
Try this:
private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e)
{
var txt = sender as TextBlock;
ToolTip tt = ToolTipService.GetToolTip(txt) as ToolTip;
tt.Content = "...";
}
And please tag your questions properly. UWP is not the same thing as WPF.