是否可以在WPF/Touch应用程序中弹出一个忽略MenuDropAlignment的弹出窗口?
作为背景知识-Windows有一个用于Touch/TabletPC的功能,它可以根据您的惯用性"改变弹出窗口/菜单的位置(以防止菜单出现在您的手下).
As a bit of background - Windows has a facility for Touch/TabletPCs whereby it shifts the position of popups/menus depending on your "handedness" (to prevent the menu appearing under your hand).
基本上,这是如果您设置为右手"(连接触摸设备后,默认情况下默认为右手操作"),则您打开的每个弹出窗口都会人为地踢向左侧-这会导致大量布局问题在这里,我们尝试将弹出式菜单与从其弹出"的项目对齐:
Essentially what this does is if you are set to "right handed" (which it seems to default to once you've connected a touch device), every popup you open is artificially kicked to the left - this causes massive layout issues where we try and line up a popup with the item it "popped up from" :
平板电脑设置为左手-Windows无需人工修正
平板电脑设置为右手-Windows会人工调整我们的位置
我们可以使用 SystemParameters.MenuDropAlignment ,对于微不足道的弹出窗口,我们可以使用弹出窗口的实际宽度进行调整-但是对于动态弹出窗口,以及当我们向左右混合添加左右支持时,这是行不通的.
We can detect what this setting is set to with SystemParameters.MenuDropAlignment, and for trivial popups we can adjust this using the actual width of the popup - but for dynamic popups and when we throw right to left support into the mix, this just doesn't work.
当前看来,我们更有可能不得不遍历每个弹出窗口,手动计算一个值以调整踢动,并向每个示例中添加类似的内容:
Currently it's looking more likely that we are going to have to go through every popup, manually work out a value to adjust the kick, and add something like this to every one:
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Source={x:Static SystemParameters.MenuDropAlignment}}" Value="True"/>
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=FlowDirection}" Value="RightToLeft"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="HorizontalOffset" Value="-50"/> <!-- Set to arbitrary value to test -->
</MultiDataTrigger.Setters>
</MultiDataTrigger>
所以..回到问题:-)有人知道一种阻止WPF弹出窗口的方法吗?
So.. back to the question :-) Does anyone know of a way to stop a WPF popup looking at this setting at all?
对于没有触摸设备的用户,可以通过运行以下命令来访问Tablet PC设置:
For those that don't have a touch device you can access the Tablet PC settings by running:
C:\ Windows \ explorer.exe shell ::: {80F3F1D5-FECA-45F3-BC32-752C152E456E}
C:\Windows\explorer.exe shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E}
看看它为自己造成的混乱:-)
And see the mess it makes for yourself :-)
这似乎是不可能的,因此我们在问题中采用MultiDataTrigger进行补偿.
It would appear this just isn't possible, so we are resorting to the MultiDataTrigger in the question to compensate.