gpt4 book ai didi

c# - UWP - Splitview 定义相对于 OpenPaneLength 的值

转载 作者:太空宇宙 更新时间:2023-11-03 23:30:03 25 4
gpt4 key购买 nike

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

谢谢!

这是 SplitViewXAML 代码

<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>

最佳答案

您只需要在IsPaneOpen 标志设置为true 时进行监控,根据其父容器的ActualWidth 计算OpenPaneLength

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


private void IsPaneOpenPropertyChanged(DependencyObject sender, DependencyProperty dp)
{
if (this.SplitView.IsPaneOpen)
{
this.SplitView.OpenPaneLength = this.LayoutRoot.ActualWidth * .8;
}
}

关于c# - UWP - Splitview 定义相对于 OpenPaneLength 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32627525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com