简体   繁体   English

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

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

I would like to change the style of an WPF popup window to look like below:我想将 WPF 弹出窗口 window 的样式更改为如下所示:

在此处输入图像描述

How can I do it?我该怎么做?

In this case the "up arrow" of the popup window is in the top left corner (more or less) but depending on the space available it could be in other places around the popup, i mean, on the left side (top, center or bottom), on the right side (top, center or bottom), on the top side (left, center or right), on the bottom side (left, center or right).在这种情况下,弹出窗口 window 的“向上箭头”位于左上角(或多或少),但根据可用空间,它可能位于弹出窗口周围的其他位置,我的意思是,在左侧(顶部,中心)或底部)、右侧(顶部、中心或底部)、顶部(左侧、中心或右侧)、底部(左侧、中心或右侧)。 I don't know who controlls it.我不知道谁在控制它。

An example of one of the possible variant:可能变体之一的示例:

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

Second variant:第二种变体:

    <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