Someone can tell you how when you click ListBoxItem to execute the command to open a new window. (MVVM) ListBox is populated via ItemSource. XAML markup like this:
<ListBox x:Name="ListBox11" MaxHeight="0" Style="{StaticResource MenuListBox}" ItemsSource="{Binding DocumentItemList}" ItemContainerStyle="{StaticResource ItemMenu}" SelectedItem="{Binding SelectedIndex}"> <i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <i:InvokeCommandAction Command="{Binding MyCommand}" CommandParameter="{Binding ElementName=ListBox11 , Path=SelectedValue}"/> </i:EventTrigger> </i:Interaction.Triggers> </ListBox> But I have no idea how to write the code.
Model: public class MenuItemModel { public bool Indicator { get; set; } public string Icon { get; set; } public string Name { get; set; } } public class MenuItemModel { public bool Indicator { get; set; } public string Icon { get; set; } public string Name { get; set; } }
VM: `public List MenuItemList {get; set; } public List DocumentItemList {get; set; }
public MenuItemViewModel() { MenuItemList = new List<MenuItemModel> { new MenuItemModel { Indicator = true, Icon = "\uf0e7", Name = "текст", }, new MenuItemModel { Indicator = false, Icon = "\uf200", Name = "текст", }, new MenuItemModel { Indicator = false, Icon = "\uf15c", Name = "текст", } }; DocumentItemList = new List<MenuItemModel> { new MenuItemModel { Indicator = true, Icon = "\uf008", Name = "текст", }, new MenuItemModel { Indicator = true, Icon = "\uf06b", Name = "текст", } }; MyCommand = new RelayCommand(() => { }); } #region Command public ICommand MyCommand { get; set; } #endregion`
А вот как код написать не имею представления.what code? Models? Teams? View models? What have you already written? - tym32167