在ViewBox中缩放组合框弹出窗口

问题描述 投票:1回答:1

我正在开发UWP应用,并且注意到将ComboBox元素(只是弹出窗口)放置在ViewBox中时缩放不正确。外观如下:

enter image description here

此外,由于组合框检测似乎与鼠标的实际位置不符,因此选择了错误的元素。 ComboBox放置在网格内其他元素的旁边(网格是ViewBox的直接子元素)。其他所有东西都可以正常工作,并且可以伸缩而不会拉伸。

在保留ViewBox的同时有什么方法可以解决此问题?预先感谢!

编辑:

    <Viewbox>
        <Grid Width="1920" Height="1280" HorizontalAlignment="Center">
            <ComboBox HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="50">
                <ComboBoxItem Content="Test123"></ComboBoxItem>
                <ComboBoxItem Content="Test456"></ComboBoxItem>
                <ComboBoxItem Content="Test789"></ComboBoxItem>
            </ComboBox>
        </Grid>
    </Viewbox>

这几乎是我要做的所有事情,我需要调整应用程序的大小并仅支持特定的分辨率(1920x1280)。它需要以某种方式适应于所有可能的Windows缩放设置。

c# xaml uwp windows-10 win-universal-app
1个回答
0
投票

Windows团队最近推出的seems to be a bug。链接文章中建议的解决方法之一是在ViewBox上添加不可见的旋转:

<Viewbox>
    <Viewbox.RenderTransform>
        <RotateTransform Angle="0.001"></RotateTransform>
    </Viewbox.RenderTransform>
    <Grid Width="1920" Height="1280" HorizontalAlignment="Center">
        <ComboBox HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="50">
            <ComboBoxItem Content="Test123"></ComboBoxItem>
            <ComboBoxItem Content="Test456"></ComboBoxItem>
            <ComboBoxItem Content="Test789"></ComboBoxItem>
        </ComboBox>
    </Grid>
</Viewbox>

当然令人作呕,这就是Microsoft建议遵循this guide查找替代性想法的原因(没有ViewBox不应被用来保持应用程序的响应速度。]

© www.soinside.com 2019 - 2024. All rights reserved.