Hi iam trying to progam an listboxitem Selected event in code because i need dynamical listboxitems.Iam coding this in wpf it works great.
<ListBoxItem Tag="cPage_Mod_Modules" Selected="ListBoxItem_Selected">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource sColor01}" Text="» " />
<TextBlock Text="Moduler" VerticalAlignment="Center" Focusable="True" />
</StackPanel>
</ListBoxItem>
the Selected="ListBoxItem_Selected" works fine.
But when iam trying to create the listboxitem in code. it doest work heres my code
IList<ListBoxItem> lbi = new List<ListBoxItem>();
ListBoxItem itemBox = new ListBoxItem();
itemBox.Tag = "cPage_Assignment_Overview";
itemBox.Selected += new EventHandler(ListBoxItem_Selected(this, null));
lbTask.Items.Add(itemBox);
I just want to route to the event ListBoxItem_Selected(object sender, RoutedEventArgs e) when somebody is selecting an item. Sorry for my bad english hope you guys understand.