2012-02-23 17 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

+0

@pivotnig - 私の答えがあなたのために問題を解決するかどうかを確認してください。 –

答えて

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

ありがとうメトロスマーフ、私はこれをチェックし、後に返信します。 :) –

+0

これは完璧に動作します。ありがとうメトロスマーフ。回答としてマーク。 –

+0

ニース!それは確かに奇妙なものでした。 –