【发布时间】:2020-05-06 08:06:20
【问题描述】:
下午好! 我有以下查看代码(部分):
<dxg:TreeListControl x:Name="TlcPropertyGroups" ItemsSource="{Binding CatalogPropertyGroups}" >
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn FieldName="Name" />
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView x:Name="TlvPropertyGroups" ShowCheckboxes="True" AllowRecursiveNodeChecking="True" ShowColumnHeaders="True" TreeDerivationMode="ChildNodesSelector" ChildNodesPath="CatalogPropertyGroupDetails" ShowIndicator="False">
<dxg:TreeListView.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<dxe:TextEdit EditMode="InplaceInactive" Text="Группы свойств"/>
<dxe:HyperlinkEdit Grid.Column="1" Text="Настроить" HorizontalAlignment="Right" Command="{Binding SettingCatalogPropertyGroupsCommand}" DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dx:DXWindow}}}"/>
</Grid>
</DataTemplate>
</dxg:TreeListView.HeaderTemplate>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding CmdTreeListViewLoaded}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</dxg:TreeListView>
</dxg:TreeListControl.View>
</dxg:TreeListControl>
有如下命令:
private RelayCommand cmdTreeListViewLoaded;
public RelayCommand CmdTreeListViewLoaded
{
get { return cmdTreeListViewLoaded ?? (cmdTreeListViewLoaded = new RelayCommand(obj =>
{
//some code
})); }
}
问题:如何将委托作为参数传递给命令(以隐藏一些表示级逻辑)? P.S.:例如,委托可能会显示一个简单的 MessageBox。
【问题讨论】:
-
见CommandParameter和stackoverflow.com/questions/6288641/…
-
这篇文章在某种程度上没有提供信息!
-
例如,我在视图中描述了一个委托: public Action
ActionMethod = str => { MessageBox.Show(str); };如何在命令参数中指定?