状態を動的に変更できるコードを実装する必要があります。
たとえば、現在のビューの向きに基づいて状態を変更する場合は、 OrientationChangedイベントのイベントハンドラを実装し、VisualStateManagerクラスのGoToStateメソッドを使用する必要があります。
参考のために次のコードサンプルを参照してください:あなたの答えのための
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="AdaptiveVisualStateGroup">
<VisualState x:Name="VisualMinWidthHeight">
<VisualState.Setters>
<Setter Target="stateTextBox.Text" Value="Visual Min Width Height" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<TextBlock x:Name="stateTextBox" Text="Current Visual State" />
DisplayInformation.GetForCurrentView().OrientationChanged += MainPage_OrientationChanged;
private void MainPage_OrientationChanged(DisplayInformation info, object args)
{
Debug.WriteLine("orientation: " + info.CurrentOrientation);
if (info.CurrentOrientation == DisplayOrientations.LandscapeFlipped || info.CurrentOrientation == DisplayOrientations.Landscape)
{
VisualStateManager.GoToState(this, "VisualMinWidthHeight", true);
}
}
感謝を。私は、質問を説明する良い仕事をしたとは思わない。 Template10フレームワークでは、VisualStateManager.GoToStateを呼び出すコードはどこにありますか?これを延長できますか?視覚的な状態の変化を待ち受けるために、各ページにコードを入れてGotoStateを呼び出す必要はありません。私はこれがブートストラップにあるかもしれませんが、私はそこにそれを見ませんでした。 – Sully
@Sullyいいですよ。上記のコードは単純な解決策または提案でした。あなたの参照のためだけです。 [StateTriggerBase](https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.statetriggerbase.aspx)を拡張して独自のカスタムトリガを作成し、StateTriggers内で使用することもできますプロパティ。 [State triggers sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlStateTriggers)では、カスタムトリガーの作成方法について説明しています。詳細は、参照することができます。 –
ありがとうXavier – Sully