WPF弹出窗口放置在QHD(联想Yoga 2 Pro)屏幕上无法正常工作

时间:2018-12-13 17:08:56

标签: wpf xaml popup

我们的应用程序中有一个弹出窗口,在所有具有不同屏幕分辨率(从1600x900,超过1920x1080到4K分辨率)的安装中都能正常工作。同样,它适用于不同的文本缩放比例(从100%到300%)。但是,在一台计算机上,弹出窗口的位置完全失真。而不是相对于父控件的顶部,左侧位置放置它,而是将其放置在它左侧的左侧? 问题计算机是带有Windows 10的Lenovo Yoga Pro 2。

以下是Viusal Studio Designer中弹出窗口的显示方式: Popup when looked up in designer

在所有Windows 10和7计算机上,相对于按钮,弹出窗口位于0,0(顶部,左侧),这很好:

This is proper position

但是,当我在Lenovo Yoga 2 Pro上运行应用程序时,它完全变形并移动到了按钮的左侧吗?当我们将其设置为相对位置并将水平偏移和垂直偏移设置为0时,这怎么可能? It is moved left?!?

这是代码:

<Window x:Class="WpfApp1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApp1"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
<Grid>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />


        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="1" Margin="15" Orientation="Horizontal" >
            <Button Name="btnLearn"
                Content="Learn About Caesar"
                Margin="5" Padding="10,5"
                VerticalAlignment="Center"
                MouseEnter="Button_MouseEnter"
                >
            </Button>
            <Popup Name="popCaesar" StaysOpen="False"
                   Placement="Relative"  HorizontalOffset="0" VerticalOffset="0"
                   PlacementTarget="{Binding ElementName=btnLearn}"
                   >
                <TextBlock Text="Julius Caesar was a Roman emperor who lived from 100 BC to 44 BC"
                    Background="AntiqueWhite"
                    Padding="5" Width="150"
                    TextWrapping="Wrap"/>
            </Popup>
        </StackPanel>

    </Grid>
</Grid>

0 个答案:

没有答案
相关问题