首页 > 解决方案 > Interaction.Triggers 数据模板列 WPF

问题描述

我有一个数据网格,我在其中声明了一个带有组合框的模板列。我的第一个想法是在 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>

在组合的下拉菜单打开之前如何为我的命令触发事件的任何想法?

谢谢安德里亚

标签: wpfmvvmcomboboxdatagridtemplatecolumn

解决方案


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

来源: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


推荐阅读