GridSplitter内的按钮不能正常工作WPF MVVM

时间:2015-10-05 13:11:35

标签: c# wpf mvvm prism

我把按钮放在了gridsplitter里面。我的目的是制作可点击的网格分割器以及可滑动的。我的问题是在将按钮放入网格分割器后,完全无法通过鼠标拖动。如何将网格分割器配置为可点击和可滑动。

<GridSplitter BorderThickness="1" HorizontalAlignment="Stretch" Grid.Column="1"  >
                <GridSplitter.Template>                        
                    <ControlTemplate TargetType="{x:Type GridSplitter}">                            
                        <Grid>
                            <Button Name="btnSplit" Content="⁞"  >
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <i:InvokeCommandAction Command="{Binding SplitterClickCommand}" CommandParameter="{Binding ElementName=btnSplit}" ></i:InvokeCommandAction>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>

                        </Grid>
                    </ControlTemplate>
                </GridSplitter.Template>
            </GridSplitter>

最好的Rgds DF

1 个答案:

答案 0 :(得分:0)

尝试在MouseDoubleClick上订阅GridSplitter个活动:

<GridSplitter BorderThickness="1" HorizontalAlignment="Stretch" Grid.Column="1"  >
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseDoubleClick">
            <i:InvokeCommandAction Command="{Binding SplitterClickCommand}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</GridSplitter>

如果MouseDoubleClick事件不适合您,您可以尝试订阅MouseDownMouseLeftButtonDown.