Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

wpf - windows 8 popup location

While porting a WPF application over to a Windows 8 instance (x64) runing under VMware, I found that all of the popups are mis-aligned against what they are supposed to be. Further investigations reveal that this is a common "problem" even for a newly created project. The popup control of WPF seems to have changed the meaning of left and right! The problem can be show by creating a wpf application using vs 2012 and put some popups in it, like:

<Grid Background="Gray">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="129*"/>
        <ColumnDefinition Width="264*"/>
        <ColumnDefinition Width="124*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="30"/>
        <RowDefinition Height="30"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <DockPanel Grid.Row="1" Grid.Column="1" Background="LightGray">
        <Popup StaysOpen="True" IsOpen="True" Grid.RowSpan="2" Placement="Right"  AllowsTransparency="True" >
            <TextBlock Text="Right" Foreground="White" />
        </Popup>
        <Popup StaysOpen="True" IsOpen="True" Grid.RowSpan="2" Placement="Left" AllowsTransparency="True"  >
            <TextBlock Text="Left" Foreground="White" />
        </Popup>
        <Popup StaysOpen="True" IsOpen="True" Grid.RowSpan="2" Placement="Top"  AllowsTransparency="True" >
            <TextBlock Text="Top" Foreground="White" />
        </Popup>
        <Popup StaysOpen="True" IsOpen="True" Grid.RowSpan="2" Placement="Bottom"  AllowsTransparency="True"  >
            <TextBlock Text="Bottom" Foreground="White" />
        </Popup>
    </DockPanel>
</Grid>

The popup that is supposed to be displayed on the left is actually displayed on the right and vice versa, the one that is supposed to be at the bottom left is displayed at bottom right, etc..

My question is: 1) is this a bug or feature? 2) if it is a feature, how to make minimun changes to the codes so that they perform in the same way inside Windows 7 and Windows 8?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Further investigation shows that there is a setting inside the Control Panel: ControlPanel->Hardware and Sound->Tablet PC (the node name maybe not exactly match since I am using a non-English version of Windows 8). There is a setting for the hand using which the user prefers to write.

One must select "I prefer writing using left hand" in order for it to place the popup in the "right position" (without using the solution above) according to the manual for .net framework. This assumption can't be right at all, at least for destop applications!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...