gpt4 book ai didi

c# - 我可以更改弹出窗口的对齐方式,使其出现在按钮的左侧而不是右侧吗?

转载 作者:行者123 更新时间:2023-11-30 22:21:35 25 4
gpt4 key购买 nike

关于如何移动位置的任何想法?这是菜单:

enter image description here

这是 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}">

注意负值 Horizo​​ntalOffsetVerticalOffset 的用法

关于c# - 我可以更改弹出窗口的对齐方式,使其出现在按钮的左侧而不是右侧吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14267986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com