こんにちは。
tabcontrolのactiveなtabによって処理を分けたいです。
Windows10, VisualStudio2015,C#6.0, Livetの組み合わせで開発しています。
MVVMモデルです。
subWindow.xamlにtabcontrolをひとつ配置しました。
subwindowの呼び出しはこんな感じです。
現在のtabage numberを保持するpropertyを用意してtabを切り替えたときに番号を保持するのか、あるいはViewのtabのactiveの状態を見るのか、MVVMだとどのようになるのでしょう。
simleなwpfならtabcrontrolとbuttonを配置して、
MessageBox.Show(
tabControl.SelectedValue.ToString());
とかで簡単にとれるのですが・・・。
よろしくお願いします。
MainWindow.cs
C#
1private void showsubwindowexecuted() 2 var vm = new SubWindowViewModel(); 3 4 var message = new TransitionMessage(vm, TransitionMode.Modal, "ShowCoordinateTransformationSettingWindow"); 5 6 while (true) 7 { 8 this.Messenger.Raise(message); 9 10 if (message.Response == true) 11 { 12 if (ここでactiveなtabpageによって処理を分けたい) 13
XAML
1<Window 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 5 xmlns:l="http://schemas.livet-mvvm.net/2011/wpf" 6 Title="tabpages" Height="350" Width="500" > 7 8 <i:Interaction.Triggers> 9 <i:EventTrigger EventName="Closed"> 10 <l:DataContextDisposeAction/> 11 </i:EventTrigger> 12 </i:Interaction.Triggers> 13 14 <Grid Margin="10,10,10,10"> 15 <Grid Grid.Row="0" Margin="0,0,0,0"> 16 <TabControl x:Name="TabControl" HorizontalAlignment="Left" Height="270" Margin="10,10,0,0" VerticalAlignment="Top" Width="450"> 17 <TabItem Header="Tab1"> 18 <Grid Background="#FFE5E5E5"> 19 </Grid> 20 </TabItem> 21 <TabItem Header="Tab2"> 22 <Grid Background="#FFE5E5E5"> 23 </Grid> 24 </TabItem> 25 <TabItem Header="Tab3"> 26 <Grid Background="#FFE5E5E5"> 27 </TabItem> 28 </TabControl> 29 </Grid> 30 </Grid> 31</Window>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/26 01:31
2016/07/26 11:29
2016/07/28 01:27