无法从Extended Toolkit DropDownButton中包含的用户控件中的Button中触发事件

时间:2012-05-10 10:52:27

标签: c# wpf mvvm-light

执行位于DataGridTemplateColumn.CellTemplate内的按钮时,我遇到了一些问题 - > DropDownButton。 Fyi,按钮嵌入在用户控件中。代码如下:

DataGrid列模板:

<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>

那么如何才能触发按钮的click事件呢? 非常感谢!

1 个答案:

答案 0 :(得分:0)

通过实现ViewModelLocator

解决