我想将WPF弹出窗口的样式更改为如下所示:
我该怎么做?在这种情况下,弹出窗口的“向上箭头”位于左上角(或多或少)但是根据可用空间的不同,它可以在弹出窗口周围的其他位置,我的意思是,在左侧。(顶部、中心或底部),右侧(上、中或下),在上边(左、中或右),在下边(左、中或右)。我不知道谁控制它。
daolsyd01#
一个可能的变体的例子:
<UniformGrid Rows="2" Columns="2"> <ToggleButton x:Name="toggleButton" Content="Some Element.
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>
1条答案
按热度按时间daolsyd01#
一个可能的变体的例子:
第二种变体: