2014-12-22 11 views
0

4 개의 단추가 명령을 바인딩하고 있으므로이 명령을 수행하려면 tabcontrols를 사용하고 싶습니다.wpf에서 tabcontrols로 단추의 명령을 변경하는 방법

SettingCmd = new RelayCommand<System.Windows.Controls.Frame> 
     (
      (f) => 
      { 
       f.Navigate(new Uri(@"View\SettingPage.xaml", UriKind.Relative)); 
      } 
     ); 

가 지금은 이러한 변화가 어떻게 버튼의 명령을 수행하기 위해 그들에게 명령을 추가 할 수 있도록, 4 개 버튼

에 따라 4 XAML 페이지가 있습니다 :

<Button Margin="5" Width="Auto" Height="26" Content="operating" Command="{Binding PCmd}" CommandParameter="{Binding ElementName=frame}"/> 
<Button Margin="5" Width="Auto" Height="26" Content="settings" Command="{Binding SettingCmd}" CommandParameter="{Binding ElementName=frame}"/> 
<Button Margin="5" Width="Auto" Height="26" Content="showing" Command="{Binding DiCmd}" CommandParameter="{Binding ElementName=frame}"/> 
<Button Margin="5" Width="Auto" Height="26" Content="controls" Command="{Binding DeviceCmd}" CommandParameter="{Binding ElementName=frame}"/> 

<Frame x:Name="frame" Source="PPage.xaml" NavigationUIVisibility="Hidden" /> 

설정은 다음과 같이 Section 명령

답변

0

프레임이 더 이상 필요하지 않으므로 각 페이지의 Xaml을 가져 와서 해당 TabItem 안에 넣는 것이 가장 좋습니다. 예를 들면 다음과 같습니다.

그들이 탐색하고이 명령에 대한 필요가 없습니다 필요 없습니다,하지만 당신은 분리 된 XAML에 각 탭의 컨텐츠를 유지를 주장하는 경우는 먼저 각 TabItem의에서 프레임을 정의해야합니다 파일 및 설정합니다이 경우
<TabItem Header="settings"> 
    //bring the Xaml of SettingPage.Xaml to here 
</TabItem> 

대응하는 Xaml 페이지에 대한 소스 속성 :

<controls:MetroAnimatedSingleRowTabControl Grid.Row="1" x:Name="MainTabControl"> 
      <TabItem Header="operating"> 
       <Frame Source="View/OperatingPage.xaml" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" NavigationUIVisibility="Hidden"/> 
      </TabItem> 
      <TabItem Header="settings"> 
       <Frame Source="View/SettingPage.xaml" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" NavigationUIVisibility="Hidden"/> 
      </TabItem> 
      <TabItem Header="showing"> 
       <Frame Source="View/ShowingPage.xaml" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" NavigationUIVisibility="Hidden"/> 
      </TabItem> 
      <TabItem Header="controls"> 
       <Frame Source="View/ControlsPage.xaml" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" NavigationUIVisibility="Hidden"/> 
      </TabItem> 
</controls:MetroAnimatedSingleRowTabControl> 

이 경우에도 모든 명령이 필요하지 않습니다.

+0

, 좋은 작품, 내가 수직으로 네 tabitems의 방향을 변경하는 방법을 알고 싶습니다 – Roger

+0

http://stackoverflow.com/questions/3953286/how-to-build-vertical-tab-sets-in-wpf – Usama