ListBoxItems
이 동적이기 때문에 코드에 ListBoxItem
Selected
이벤트를 프로그래밍하려고합니다. 내가 WPF이 코딩하고, 다음 XAML 잘 작동합니다 :C# program selected 코드의 이벤트
<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>
Selected="ListBoxItem_Selected"
가 잘 작동합니다.
그러나 코드에서 ListBoxItem
을 만들려고해도 작동하지 않습니다. 누군가가 항목을 선택하면 난 그냥 이벤트 ListBoxItem_Selected(object sender, RoutedEventArgs e)
로 라우팅 할
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);
: 여기 내 코드입니다.
덕분에 같은 선언 – Tan