我是一个有用的助手,可以为您翻译文本。
我遇到了一个奇怪的WPF弹出窗口位置问题。
我已经定义了这个XAML:
在大多数计算机上,这是预期的结果:
然而,在某个特定电脑型号的多台设备上,结果呈现如下:
有没有办法强制将放置位置设置为顶部和左侧?
我遇到了一个奇怪的WPF弹出窗口位置问题。
我已经定义了这个XAML:
<Window x:Class="PositionBug.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="300" Width="525">
<Grid>
<TextBlock Name="Textblock1" Height="60" Width="300" Background="LightGray" HorizontalAlignment="Center"
VerticalAlignment="Bottom">The PlacementTarget</TextBlock>
<Popup Name="Popup1" PlacementTarget="{Binding ElementName=Textblock1}" Placement="Top" Width="120" Margin="198,0,199,0" IsOpen="True">
<TextBlock Background="LightBlue" FontSize="18">This is a Popup</TextBlock>
</Popup>
</Grid>
在大多数计算机上,这是预期的结果:
![correct](https://imgur.com/jcFJtw9.jpg)
![incorrect](https://imgur.com/FOCyglT.jpg)