标签:RoCE hang control 打开 nta dock ram pre tar
原文:WPF MVVM COMMOND 传参
一、直接绑定(对于有事件的控件可以通过直接绑定的方式)
1、view
-
hc:SideMenuItem Header="接谈中" Cursor="Hand" Command="{Binding AddTabItemCommand}" CommandParameter="PDjtList.xaml">
-
-
Image Source="/Images/icons/jtz.png" Width="24" Height="24"/>
-
-
2、viewmodel
-
-
-
-
public RelayCommandstring> AddTabItemCommand =>
-
-
new RelayCommandstring>(AddTabItem)).Value;
-
-
-
-
-
-
-
private void AddTabItem(string param)
-
-
-
-
-
二、EventTrigger绑定(对于通过datatemp遍历的控件没有事件可以绑定的情况,如listbox)
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
-
"sideMenu" SelectedIndex="{Binding MenuSelectedIndex}" ItemsSource="{Binding MenuList}" BorderThickness="0" SelectionMode="Single">
-
-
-
-
"20" Height="20" Source="{Binding Icons}"/>
-
"10,12,0,0" FontSize="14" Text="{Binding Title}"/>
-
"param" Visibility="Hidden" Text="{Binding Url}"/>
-
-
-
-
-
-
"{Binding ElementName=sideMenu, Path=DataContext.SelectMenuCommand}" PassEventArgsToCommand="True" />
-
-
-
-
-
-
-
public RelayCommand SelectMenuCommand =>
-
-
new RelayCommand(SelectMenu)).Value;
-
-
-
-
-
private void SelectMenu(SelectionChangedEventArgs e)
-
-
if (e.AddedItems.Count == 0) return;
-
if (e.AddedItems[0] is MenuInfo item)
-
-
if (Equals(_selectedMenu, item)) return;
-
-
-
DataList.Add(new TabControlModel
-
-
-
-
-
TabSelectedIndex = DataList.ToArray().Length - 1;
-
-
-
三、Image点击事件
-
"img_verifycode" Height="40" Margin="0,10,30,0" Source="{Binding VerifyCode}">
-
-
-
"{Binding ElementName=img_verifycode, Path=DataContext.SwitchVerifyCodeCommand}" />
-
-
WPF MVVM COMMOND 传参
标签:RoCE hang control 打开 nta dock ram pre tar
原文地址:https://www.cnblogs.com/lonelyxmas/p/12164917.html