トップ回答者
MVVM 画面遷移について

質問
回答
-
Behaviorで表示してる前提だと以下のような感じでいけます。
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:Custom="http://schemas.livet-mvvm.net/2011/wpf" x:Class="LivetNav.Views.LoginWindow" xmlns:Views="clr-namespace:LivetNav.Views" Title="LoginWindow" Height="300" Width="300"> <Grid> <Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Custom:TransitionInteractionMessageAction IsOwned="False"> <Custom:DirectInteractionMessage> <Custom:TransitionMessage WindowType="{x:Type Views:MenuWindow}" /> </Custom:DirectInteractionMessage> </Custom:TransitionInteractionMessageAction> <Custom:WindowInteractionMessageAction> <Custom:DirectInteractionMessage> <Custom:WindowActionMessage Action="Close" /> </Custom:DirectInteractionMessage> </Custom:WindowInteractionMessageAction> </i:EventTrigger> </i:Interaction.Triggers> </Button> </Grid> </Window>
BehaviorのActionには複数Actionが設定可能なので、Window開くActionと閉じるActionを設定すればいけます。かずき Blog:http://d.hatena.ne.jp/okazuki/
すべての返信
-
Behaviorで表示してる前提だと以下のような感じでいけます。
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:Custom="http://schemas.livet-mvvm.net/2011/wpf" x:Class="LivetNav.Views.LoginWindow" xmlns:Views="clr-namespace:LivetNav.Views" Title="LoginWindow" Height="300" Width="300"> <Grid> <Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Custom:TransitionInteractionMessageAction IsOwned="False"> <Custom:DirectInteractionMessage> <Custom:TransitionMessage WindowType="{x:Type Views:MenuWindow}" /> </Custom:DirectInteractionMessage> </Custom:TransitionInteractionMessageAction> <Custom:WindowInteractionMessageAction> <Custom:DirectInteractionMessage> <Custom:WindowActionMessage Action="Close" /> </Custom:DirectInteractionMessage> </Custom:WindowInteractionMessageAction> </i:EventTrigger> </i:Interaction.Triggers> </Button> </Grid> </Window>
BehaviorのActionには複数Actionが設定可能なので、Window開くActionと閉じるActionを設定すればいけます。かずき Blog:http://d.hatena.ne.jp/okazuki/