开发者

Touch issue on ListBox

开发者 https://www.devze.com 2023-03-10 01:25 出处:网络
I have this ListBox in my xaml.开发者_C百科 FIRST.XAML <ListBox ItemsSource=\"{Binding Items}\" x:Name=\"newsList\"

I have this ListBox in my xaml.

开发者_C百科
FIRST.XAML

<ListBox ItemsSource="{Binding Items}" x:Name="newsList" 
   ItemTemplate="{StaticResource NewsListTemplate}"
   Margin="-2,86,2,0" SelectionChanged="openNewsViewer" 
   Height="361" VerticalAlignment="Top" d:LayoutOverrides="GridBox"
/>

The problem is that when I click first time on a list item, all ok, it calls SECOND.XAML correctly, but, when I go back to FIRST.XAML from SECOND.XAML, I'm unable to re-click at the same ListBox item!

But why?

Here C# code:

private void openNewsViewer(object sender, SelectionChangedEventArgs e)
{
    var listbox = (ListBox)sender;
    var entry = (ItemViewModel)listbox.SelectedItem;

    Navigate(entry.Link, entry.LineOne, true);
}

private void Navigate(string url, string title, bool showAppBar)
{
    var uri = "/NewsViewer.xaml?idx=" + url + "&title=" + title + "&appbar=" + (showAppBar == true ? "true" : "false");
    NavigationService.Navigate(new Uri(uri, UriKind.Relative));
}

It's all!

Any idea to solve this issue?

Thanks!

EDIT 1:

Second click on the same row NOT CALL openNewsViewer. It could be a problem in XAML file?

Please help me.

thanks^2!


The problem is that your event fires when page is reloaded ( when your listbox is created the selectedItem is changed).

You can use ManipulationStarted event.

0

精彩评论

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