1

我正在使用新SplitView控件在我的应用程序中创建汉堡菜单UWP。我的问题是我是否可以为其OpenPaneLength属性定义相对值或百分比值?我想实现SplitView's的宽度Pane例如是设备宽度的 80%。

谢谢!

这是XAML代码SplitView

<SplitView x:Name="ShellSplitView"
           DisplayMode="Overlay"
           IsPaneOpen="False"
           OpenPaneLength="300">
    <SplitView.Pane>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <RadioButton x:Name="SettingsButton"
                         Grid.Row="1"
                         Content="Settings"
                         Checked="OnSettingsButtonChecked" />
        </Grid>
    </SplitView.Pane>
    <SplitView.Content>...</SplitView.Content>
</SplitView>
4

1 回答 1

3

您只需要在IsPaneOpen标志设置为时进行监控trueOpenPaneLength根据其父容器的ActualWidth.

this.SplitView.RegisterPropertyChangedCallback(SplitView.IsPaneOpenProperty, IsPaneOpenPropertyChanged);


private void IsPaneOpenPropertyChanged(DependencyObject sender, DependencyProperty dp)
{
    if (this.SplitView.IsPaneOpen)
    {
        this.SplitView.OpenPaneLength = this.LayoutRoot.ActualWidth * .8;
    }
}
于 2015-09-17T11:17:08.393 回答