Interaction.Triggers datatemplate列WPF

时间:2018-06-11 17:03:41

标签: wpf mvvm combobox datagridtemplatecolumn

我有一个datagrid,我在其中使用组合框声明了一个模板comlumn。 我的第一个想法是在PreparingCellForEdit上触发Interaction.Trigger,但是带有组合的模板列没有触发它。 我试图将交互触发器放在组合上,它甚至不会触发DropDown

<WPFCtrlD:ExtDataGridTemplateColumn Header="{x:Static Translate:Translate.About}" Width="*" Tag="ID_SAP_MAPPING"
                                           IsReadOnly="False"  >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <!--Visibility="{Binding IsClassSelected, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,  
                                        Converter={StaticResource  BoolToVisibilityCollapsedInverteConverter }}"-->
                                <ComboBox ItemsSource="{Binding DataContext.characteristicFiltered,
                                Source={StaticResource ProxyElement}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged }"
                                       SelectedValuePath="ID_SAP_NAME"
                                                DisplayMemberPath="ID_SAP_NAME"
                                   >
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="DropDown">
                                            <WPFCtrl:EventToCommand 
                                                PassEventArgsToCommand="True"
                                                Command="{Binding DataContext.PreparingCellForEditCommand, Source={StaticResource ProxyElement}}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </ComboBox>
                                <!--<Label Visibility="{Binding IsClassNotSelected, Mode=OneWay, UpdateSourceTrigger=PropertyChanged,  
                                       Converter={StaticResource  BoolToVisibilityCollapsedInverteConverter }}"/>-->
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </WPFCtrlD:ExtDataGridTemplateColumn>

在组合下拉列表打开之前,有关如何为我的命令触发事件的任何想法吗?

谢谢你 安德烈

1 个答案:

答案 0 :(得分:0)

我相信我们在WPF中使用的ComboBox来自System.Windows.Controls命名空间,该命名空间使用 DropDownOpened 事件。

来源:https://msdn.microsoft.com/en-us/library/system.windows.controls.combobox.dropdownopened(v=vs.110).aspx

另一方面,如果您正在使用System.Windows.Forms命名空间中存在的ComboBox,则它使用 DropDown 事件。

来源:https://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.dropdown(v=vs.110).aspx