简体   繁体   English

UWP:如何在关闭窗格时指定窗格边框?

[英]UWP: How to specify pane border when the pane is close?

Just a quick question, I am using SplitView and I tried to create a left border when the pane is closed. 只是一个简单的问题,我正在使用SplitView,并且在关闭窗格时尝试创建左边框。 (Note: I placed the pane on the right). (注意:我将窗格放在右侧)。

Is it possible? 可能吗? I've tried: 我试过了:

<SplitView DisplayMode="CompactOverlay" IsPaneOpen="False" OpenPaneLength="320" PanePlacement="Right">
    <SplitView.Pane>
        <Border BorderBrush="black" BorderThickness="1 0 0 0">
            ...
            ...
            ...
        </Border>
    </SplitView.Pane>
    <SplitView.Content>
        ...
        ...
        ...
    </SplitView.Content>
</SplitView>

But the border only appear when I open the pane. 但是边框仅在我打开窗格时出现。

Sorry for this silly question, but UWP is new to me. 很抱歉这个愚蠢的问题,但是UWP对我来说是新的。

Thanks. 谢谢。

It is not possible using the default style of the control. 无法使用控件的默认样式。 By default, the pane visibility is set to collapsed when the IsPaneOpen property is set to false 默认情况下,当IsPaneOpen属性设置为false时,窗格的visibility设置为collapsed

If you want to do so, you will have to create your own style for the splitview. 如果要这样做,则必须为splitview创建自己的样式。

Here is the default style (visual state manager has been removed) 这是默认样式(视觉状态管理器已删除)

<Style TargetType="SplitView">
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
    <Setter Property="OpenPaneLength" Value="{ThemeResource SplitViewOpenPaneThemeLength}"/>
    <Setter Property="CompactPaneLength" Value="{ThemeResource SplitViewCompactPaneThemeLength}"/>
    <Setter Property="PaneBackground" Value="{ThemeResource SystemControlPageBackgroundChromeLowBrush}"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="SplitView">
                <Grid Background="{TemplateBinding Background}">


                    <!-- Content Area -->
                    <Grid x:Name="ContentRoot" Grid.ColumnSpan="2">
                        <Border Child="{TemplateBinding Content}"/>
                        <Rectangle x:Name="LightDismissLayer" Fill="Transparent" Visibility="Collapsed"/>
                    </Grid>

                    <!-- Pane Content Area-->
                    <Grid
                        x:Name="PaneRoot"
                        Grid.ColumnSpan="2"
                        HorizontalAlignment="Left"
                        Visibility="Collapsed"
                        Background="{TemplateBinding PaneBackground}"
                        Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.OpenPaneLength}">
                        <Grid.Clip>
                            <RectangleGeometry x:Name="PaneClipRectangle">
                                <RectangleGeometry.Transform>
                                    <CompositeTransform x:Name="PaneClipRectangleTransform"/>
                                </RectangleGeometry.Transform>
                            </RectangleGeometry>
                        </Grid.Clip>
                        <Grid.RenderTransform>
                            <CompositeTransform x:Name="PaneTransform"/>
                        </Grid.RenderTransform>
                        <Border Child="{TemplateBinding Pane}"/>
                        <Rectangle
                            x:Name="HCPaneBorder"
                            x:DeferLoadStrategy="Lazy"
                            Visibility="Collapsed"
                            Fill="{ThemeResource SystemControlForegroundTransparentBrush}"
                            Width="1"
                            HorizontalAlignment="Right"/>
                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

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

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