0

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

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>

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

4

1 回答 1

0

通过实现 ViewModelLocator 解决

于 2012-05-11T01:26:34.613 回答