繁体   English   中英

如何更改 WPF 弹出窗口的样式 window

[英]How to change style of an WPF popup window

我想将 WPF 弹出窗口 window 的样式更改为如下所示:

在此处输入图像描述

我该怎么做?

在这种情况下,弹出窗口 window 的“向上箭头”位于左上角(或多或少),但根据可用空间,它可能位于弹出窗口周围的其他位置,我的意思是,在左侧(顶部,中心)或底部)、右侧(顶部、中心或底部)、顶部(左侧、中心或右侧)、底部(左侧、中心或右侧)。 我不知道谁在控制它。

可能变体之一的示例:

    <UniformGrid Rows="2" Columns="2">
        <ToggleButton x:Name="toggleButton" Content="Some Element.&#xd;&#xa;Click for Popup"/>
        <Popup IsOpen="{Binding IsChecked, ElementName=toggleButton}"
               PlacementTarget="{Binding ElementName=toggleButton, Mode=OneWay}"
               AllowsTransparency="True">
            <Grid>
                <Path Fill="LightYellow" Stroke="LightGray">
                    <Path.Data>
                        <CombinedGeometry GeometryCombineMode="Union">
                            <CombinedGeometry.Geometry1>
                                <RectangleGeometry Rect="0,10 100,200"/>
                            </CombinedGeometry.Geometry1>
                            <CombinedGeometry.Geometry2>
                                <RectangleGeometry Rect="40,0 20,20">
                                    <RectangleGeometry.Transform>
                                        <RotateTransform Angle="45" CenterX="40"/>
                                    </RectangleGeometry.Transform>
                                </RectangleGeometry>
                            </CombinedGeometry.Geometry2>
                        </CombinedGeometry>
                    </Path.Data>
                </Path>
                <TextBlock Text="Popup text" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </Grid>
        </Popup>
    </UniformGrid>

第二种变体:

    <CombinedGeometry GeometryCombineMode="Union">
        <CombinedGeometry.Geometry1>
            <!--Vertical offset by the height of the arrow-->
            <RectangleGeometry Rect="0,30 100,200"/>
        </CombinedGeometry.Geometry1>
        <CombinedGeometry.Geometry2>
            <!--Arrow shape-->
            <PathGeometry Figures="M0,30 L10,0 L20,30 Z">
                <PathGeometry.Transform>
                    <!--Arrow position-->
                    <TranslateTransform X="30"/>
                </PathGeometry.Transform>
            </PathGeometry>
        </CombinedGeometry.Geometry2>
    </CombinedGeometry>

在此处输入图像描述

暂无
暂无

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

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