1

在 WPF 中,我使用 DoubleClick 事件处理程序创建了一个 CustomUserControl。我以这种方式在 ControlTemplate 中使用此控件:

             <xcdg:DataCell FieldName="."  Template="{StaticResource myTemplate}">
                </xcdg:DataCell>

这也是我的 ControlTemplate:

    <ControlTemplate x:Key="myTemplate" TargetType="xcdg:DataCell">
                        <uicontrols:MyCustomControl  Tag="{Binding ID}"  Margin="0"  Height="140" Width="150" DoubleClick="ctrl_DoubleClick">
    </ControlTemplate>

DoubleClick 事件处理程序在 ControlTemplate 中不起作用。什么是问题,什么是最好的解决方案?

4

1 回答 1

0

我发现了我的答案。而不是在 DateCell 中使用额外的模板。我使用了内联模板。

<xcdg:DataCell FieldName=".">
 <xcdg:DataCell.Template>
   <ControlTemplate> 
     // your template code. here the event of my controls are working.
   </ControlTemplate>
 </xcdg:DataCell.Template>
</xcdg:DataCell>
于 2016-02-26T16:50:00.677 回答