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

Disable ListBox item in WPF

$
0
0

Hi Guys, I have a simple ListBox laoded in WPF & I want to disable some items. How can i do this?

<ListBox Margin="10,55,0,0" x:Name="listBox1"  FontSize="18" SelectionChanged="listBox1_SelectionChanged"
            	HorizontalAlignment="Left" VerticalAlignment="Top" Width="130" Height="200"  Background="GhostWhite"/>

ListBox values:

           public TreeviewTest()
        {
            InitializeComponent();

List<String> listOfNames = new List<String>() { "Animals", "Plants", "Nature", "Science", "People" }; Binding myBinding = new Binding(); //set binding parameters if necessary myBinding.Source = listOfNames; listBox1.SetBinding(ItemsControl.ItemsSourceProperty, myBinding);

}


I want to disable 'Nature' & 'People' in the ListBox. Thank you.

Karthik



Viewing all articles
Browse latest Browse all 18858

Trending Articles



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