无法从扩展工具包下拉列表按钮中包含的用户控件中的按钮触发事件
本文关键字:按钮 控件 用户 事件 包含 工具包 下拉列表 扩展 | 更新日期: 2023-09-27 18:33:56
我在执行位于DataGridTemplateColumn.CellTemplate -> DropDownButton中的按钮时遇到了一些问题。仅供参考,该按钮嵌入在用户控件中。代码如下:
数据网格列模板:
<Custom:DataGridTemplateColumn Header="Status">
<Custom:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<extToolkit:DropDownButton Width="Auto"
Height="Auto"
Content="Request"
>
<extToolkit:DropDownButton.DropDownContent>
<local:ButtonGroup />
</extToolkit:DropDownButton.DropDownContent>
</extToolkit:DropDownButton>
</DataTemplate>
</Custom:DataGridTemplateColumn.CellTemplate>
</Custom:DataGridTemplateColumn>
查看型号 :
ButtonSetStatusEvent = new RelayCommand(new Action<object>(SetStatus));
public ICommand ButtonSetStatusEvent
{
get
{
return m_ButtonSetStatusEvent;
}
set
{
m_ButtonSetStatusEvent = value;
}
}
private void SetStatus(object o)
{
if (o.ToString() == "CmdWait")
{
coStatus = (int)Status.Waiting;
CoStatusDisplay = Status.Waiting.ToString();
}
}
按钮触发器 XAML :
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding RelativeSource= {RelativeSource FindAncestor,
AncestorType=local:GridOverview,
AncestorLevel=1},
Path=DataContext.ButtonSetStatusEvent}"
CommandParameter="CmdWait"
PassEventArgsToCommand="False" />
</i:EventTrigger>
</i:Interaction.Triggers>
那么,如何触发按钮的点击事件呢?多谢!
通过实现视图模型定位器来解决