2012-02-23 83 views
3

有沒有人遇到Windows Phone 7.1的這個問題?當頁面方向更改時,滑塊控件無法正確調整大小

我有一個簡單的頁面,其頂部的拉伸控件位於全寬度範圍內。該頁面支持方向更改。

如果您運行該應用程序並以縱向模式啓動,請將滑塊置於該欄的中間。現在改變方向,讓你處於lanscape模式。現在將滑塊完全移到右側(最大值)。現在回到肖像 - 你看到了什麼?

我看到一個滑塊,但該按鈕不在屏幕上,如果我點擊滑塊中的任何位置來移動條形按鈕,則需要嘗試幾次。這似乎正在發生,因爲滑塊沒有正確重新調整大小。這似乎只在滑塊值處於最大值時纔會發生。

有其他人看過這個問題嗎?在模擬器和我的HTC Mozart設備上的問題是相同的。

嘗試了這一點,在風景模式下運行它,移動滑塊一直向右,然後切換到肖像模式,並注意滑塊到底現在是不可見的。

<phone:PhoneApplicationPage 
x:Class="SliderRedrawPageOrientation.MainPage" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" 
FontFamily="{StaticResource PhoneFontFamilyNormal}" 
FontSize="{StaticResource PhoneFontSizeNormal}" 
Foreground="{StaticResource PhoneForegroundBrush}" 
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" 
shell:SystemTray.IsVisible="True"> 

<!--LayoutRoot is the root grid where all page content is placed--> 
<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <!--TitlePanel contains the name of the application and page title--> 
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> 
     <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/> 
     <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
    </StackPanel> 

    <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <Slider HorizontalAlignment="Stretch"></Slider> 
    </Grid> 
</Grid> 

+0

您是否找到解決您的問題的方法?我有同樣的問題... – thumbmunkeys 2012-04-15 12:05:38

+0

@pivotnig - 看我的答案是否能解決你的問題。 – 2012-04-27 22:16:24

回答

2

我可以重現這個問題,甚至當滑塊按鈕小於MaxValue它發生。這是一個解決方案,使用BackgroundWorker並快速打盹;有點破解,但它確實解決了這個問題:

public MainPage() 
{ 
    InitializeComponent(); 

    this.OrientationChanged += OnOrientationChanged; 
} 

private void OnOrientationChanged(object sender, OrientationChangedEventArgs e) 
{ 
    double val = MySlider.Value; 
    MySlider.Value = 0; 

    var bw = new BackgroundWorker(); 
    bw.DoWork += (_, __) => Thread.Sleep(100); 
    bw.RunWorkerCompleted += (_, __) => Dispatcher.BeginInvoke(() => MySlider.Value = val); 
    bw.RunWorkerAsync(); 
} 
+0

感謝Metro Smurf,我會檢查出來後回傳。 :) – 2012-05-03 12:46:03

+0

完美的作品。由於地鐵Smurf。標記爲已回答。 – 2012-05-04 10:49:02

+0

不錯!這確實是一個奇怪的。 – 2012-05-04 14:41:11

相關問題