Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Get selected Listbox item

$
0
0

hi,

Can someone tell me  how to know which listboxitem from a listbox was selected by the user?

This is the listboxitem.

<ListBoxItem HorizontalAlignment="Left" Name="Canvas" Foreground="White"  FontSize="60" Background="White" BorderBrush="White" Width="763" Height="72"  >

The following are not working

 if (MyList.SelectedItem.ToString() == "Canvas")
            {
                canvaswindow cw = new canvaswindow();
                cw.Show();
                this.Close();
            }


 private void ListBoxItem_Selected_1(object sender, RoutedEventArgs e)
        {
            if (MyList.SelectedItem.ToString() == "Canvas")
            {
                canvaswindow cw = new canvaswindow();
                cw.Show();
                this.Close();
            }
        }

Thanks,

Shaleen


TheHexLord


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>