locked
How way to check "SelectionChanged" of listview,... inside hub? RRS feed

  • Question

  • There are listbox and combobox.

    Listbox

     private async void List_SeletedChanged (object sender, SelectionChangedEventArgs e)
    { var Items = ((ListBox)sender).SelectedItem as ViewModel.CategoryMusic; if(Items!=null) { if (Items.Title != null) { IdAb=Items.IdAlbum;

    checkAb=true; } } }

    Combobox
    private async void Combo_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                try
                {
                    var Items = ((ComboBox)sender).SelectedItem as ViewModel.Geners;
                    if (Items != null)
                    {
                        if (Items.Id != null)
                        {
                            if (checkAb)
                            {
                                Launch.Source = await ProductComand.GetTopProduct(Items.Id, IdAb);
                            }

    <ItemsControl x:Name="LstMu"

    Background="Transparent" Foreground="Black"

    FontFamily="Segoe WP Light" FontSize="15"

    ItemsSource="{Binding Source={StaticResource Launch}" >

    All code were laying inside hub.
    The first on loading on listbox then It be Ok.Because of Listbox will  take seletedItems valueby default and combobox also take seletecItems value by default

    I got a problem is that when I changed "SelectedItem" on listbox then it could not access data  to Launch. I must changed value of combobox on xaml then It could access data to Launch.

    I want if no change on combobox but changed on listbox then it could access data to Launch( keep seletedItem on combobox on the first  of app are loading.).

    I don't understand this part so I can't explain as clearly.





    Wednesday, May 6, 2015 3:11 PM

Answers

  • Hi Greg Heffey,

    >>I got a problem is that when I changed "SelectedItem" on listbox then it could not access data  to Launch. I must changed value of combobox on xaml then It could access data to Launch.

    I am not sure if I have misunderstood you, in my mind because you have used the following code inside the Combo_SelectionChanged event:

    Launch.Source = await ProductComand.GetTopProduct(Items.Id, IdAb);

    So if you do not change the value of the ComBobox, then the Combo_SelectionChanged event will not been fired, so this code (Launch.Source = await ProductComand.GetTopProduct(Items.Id, IdAb))will not been executed, then we can not access the data to the Launch.

    >>I want if no change on combobox but changed on listbox then it could access data to Launch( keep seletedItem on combobox on the first  of app are loading.).

     If you want to implement the above function, please move this code(Launch.Source = await ProductComand.GetTopProduct(Items.Id, IdAb)) outside of the Combo_SelectionChanged event, for example you can put the code inside the Button Click event. In this way we can execute the Lauch.Source code without changing the SelectedItem of the ComboBox.
    If I have misunderstood you, please feel free to let me know.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Thursday, May 7, 2015 8:21 AM
    Moderator