我有一个简单的 WPF 弹出窗口,当用户点击按钮时我会显示它。
<Button
x:Name="aButton"
Content="Up/Down"
Width="75"
Height="30"
Click="aButton_Click"
/>
<Popup
PlacementTarget="{Binding ElementName=aButton}"
Placement="Right"
VerticalOffset="-31"
StaysOpen="False"
AllowsTransparency="True"
>
<StackPanel>
<Button Width="45" Height="45" Margin="2,0,2,2" Content="+"/>
<Button Width="45" Height="45" Margin="2,0,2,0" Content="-"/>
</StackPanel>
</Popup>
非常奇怪的是,这段代码在运行的机器不同上表现出不同的结果。我在我的台式电脑上运行它,一切运行得很好…也像它应该的那样。但是我在我的PDC09上运行它……弹出窗口的位置与我使用“Placement”属性告诉它的位置相反(在左侧而不是右侧)。
为什么会这样?我能做些什么来解决它?