【问题标题】:UWP: How to specify pane border when the pane is close?UWP:当窗格关闭时如何指定窗格边框?
【发布时间】:2016-05-11 11:19:02
【问题描述】:

只是一个简单的问题,我正在使用 SplitView,并尝试在窗格关闭时创建左边框。 (注意:我将窗格放在右侧)。

有可能吗?我试过了:

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

但边框只有在我打开窗格时才会出现。

抱歉这个愚蠢的问题,但 UWP 对我来说是新的。

谢谢。

【问题讨论】:

    标签: c# xaml win-universal-app windows-10-universal


    【解决方案1】:

    无法使用控件的默认样式。 默认情况下,当IsPaneOpen 属性设置为false 时,窗格visibility 设置为collapsed

    如果您想这样做,您必须为拆分视图创建自己的样式。

    这是默认样式(视觉状态管理器已被移除)

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-05
      • 2017-06-23
      • 2021-04-08
      • 1970-01-01
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多