简体   繁体   English

当SplitView处于压缩模式时,拉伸SplitView.Pane的内容

[英]Stretch content of SplitView.Pane when SplitView is in Compact mode

I'm trying to create a navigation bar using the SplitView control. 我正在尝试使用SplitView控件创建导航栏。 I set it's DisplayMode property to CompactInline and two different values for CompactPaneLength and OpenPaneLength properties. 我将其DisplayMode属性设置为CompactInline,并将CompactPaneLength和OpenPaneLength属性设置为两个不同的值。 Problem is when SplitView gets closed (compacted), content of it's Pane won't be aware of new size so if I put a let's say Border element in it, the element won't be stretched and goes out of the compact pane area: 问题是,当SplitView被关闭(压缩)时,其Pane的内容将不会知道新的大小,因此,如果我在其中放置Border元素,该元素将不会被拉伸并离开紧凑窗格区域:

 <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <SplitView IsPaneOpen="False" CompactPaneLength="100" OpenPaneLength="200" DisplayMode="CompactInline">
        <SplitView.Pane>
            <Border BorderBrush="Blue" Height="50"
                    BorderThickness="4"
                    VerticalAlignment="Top">
                <FontIcon Glyph="&#xE094;"
                          Width="40"
                          Height="40" />
            </Border>
        </SplitView.Pane>
    </SplitView>
</Grid>

Here is an image demonstrates the problem: 这是一个演示问题的图像:

SplitView窗格

Question is: How to solve the problem without using the event handlers and code behind? 问题是:如何在不使用事件处理程序和代码的情况下解决问题?

Your compactPane width is set to 100 px. 您的compactPane宽度设置为100像素。 Since the border is not limited in width, it will strech, becoming 100 px. 由于边框的宽度不受限制,因此它将拉伸,变为100 px。 The content of border will center. 边框的内容将居中。

Set CompactPane width to 50, or the border width to 50 to resolve the issue 将CompactPane宽度设置为50,或将边框宽度设置为50以解决该问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM