开发者

OnClick on generated Textblock

开发者 https://www.devze.com 2023-02-02 07:42 出处:网络
Howdy, I\'m开发者_如何学C generating a bunch of Textblocks in a StackPanel. I would love to open another page when clicking on one Textbox:

Howdy, I'm开发者_如何学C generating a bunch of Textblocks in a StackPanel. I would love to open another page when clicking on one Textbox:

sp.Children.Add(new TextBlock { Text = "Click me, I wanna open new content" });

How could I do that, it's probably something with "triggers" but I couldn't find anything on the web :-/.

Thanks!


You could use the Toolkit to add a gesture listener for the Tap event.

Alternatively you could use a HyperlinkButton as this contains a Click event.

Edit:
Example of using HyperlinkButton:

var sp = new StackPanel();

var hlb = new HyperlinkButton {Content = "click me"};
hlb.Click += hlb_Click;

sp.Children.Add(hlb);

ContentPanel.Children.Add(sp);


private void hlb_Click(object sender, RoutedEventArgs e)
{
    NavigationService.Navigate(new Uri("/AnotherPage.xaml", UriKind.Relative));
}


Use TextBlock.ManipulationStarted event to detect a touch on it.

0

精彩评论

暂无评论...
验证码 换一张
取 消