关于如何移动位置的任何想法?这是菜单:
这是 XAML:
<Canvas MinHeight="25" Panel.ZIndex="99">
<ToggleButton x:Name="btnPluginMenu" Content="CT" Width="48" Height="48" Canvas.Left="452" Canvas.Top="263"/>
<Popup Placement="Top" PlacementTarget="{Binding ElementName=btnPluginMenu}" IsOpen="{Binding ElementName=btnPluginMenu, Path=IsChecked}">
<Grid Background="Gray" Width="175" Height="130">
<Grid.BitmapEffect>
<DropShadowBitmapEffect />
</Grid.BitmapEffect>
</Grid>
</Popup>
</Canvas>
最佳答案
来自 MSDN您可以使用 Placement=Relative
模式:
A position of the Popup control relative to the upper-left corner of the PlacementTarget and at an offset that is defined by the HorizontalOffset and VerticalOffset property values. If the screen edge obscures the Popup, the control repositions itself to align with the screen edge.
换句话说,你可以这样做:
<ToggleButton x:Name="btnPluginMenu" Content="CT" Width="48" Height="48" Canvas.Left="452" Canvas.Top="263"/>
<Popup Placement="Relative" HorizontalOffset="-120" VerticalOffset="-130" PlacementTarget="{Binding ElementName=btnPluginMenu}" IsOpen="{Binding ElementName=btnPluginMenu, Path=IsChecked}">
注意负值 HorizontalOffset
和 VerticalOffset
的用法
关于c# - 我可以更改弹出窗口的对齐方式,使其出现在按钮的左侧而不是右侧吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14267986/