2016-02-23 107 views
0

我在我的視圖中有一個選項卡控件,綁定到可觀察的集合。但是當我打電話給RaisePropertyChanged沒有更新。啓用的選項卡可以,但選項卡內的視圖不會。如何刷新我的數據模板中的視圖?如何更新TabControl資源?

<TabControl IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding DeviceListViewModel.SelectedDevice.TabViewModelsCollection, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding DeviceListViewModel.SelectedDevice.SelectedTabItemVm}" > 
       <TabControl.Resources> 
        <DataTemplate DataType="{x:Type vms:HomeViewModel}"> 
         <local:HomeTab/> 
        </DataTemplate> 
        <DataTemplate DataType="{x:Type vms:ConfigurationViewModel}"> 
         <Grid> 
          <local:ConfigurationFileView Visibility="{Binding Configuration, TargetNullValue=Collapsed, FallbackValue=Visible}"/> 
          <local:ErrorTab Visibility="{Binding Path= Configuration, TargetNullValue=Visible, FallbackValue=Hidden}"/> 
         </Grid> 
        </DataTemplate> 
        <DataTemplate DataType="{x:Type vms:ExpansionModulesViewModelFactory}"> 
         <Grid> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="*"/> 
           <RowDefinition Height="35"/> 
          </Grid.RowDefinitions> 
          <StackPanel Grid.Row="0"> 
           <DockPanel > 
            <local:ExpansionModulesList Title="Discovered/Enumerated" 
                 DataContext="{Binding DiscoveredModules}" 
                 /> 
            <GridSplitter Width="5"/> 
            <local:ExpansionModulesList Title="User Action Required" 
                 DataContext="{Binding FaultyModules}" 
                 /> 
           </DockPanel> 
          </StackPanel> 
          <DockPanel Grid.Row="1"> 
           <StackPanel Orientation="Horizontal" FlowDirection="RightToLeft" Margin="5" IsEnabled="{Binding IsCommandEnabled}"> 
            <Button Content="Cancel" HorizontalAlignment="Right"    
              Command="{Binding CancelExpansionCommand }" 
              ToolTip="Revert all local modifications by refreshing data from the controller." />                                 
            <Separator Width="10"/> 

            <Button Content="Apply" HorizontalAlignment="Center"       
              Command="{Binding ApplyExpansionCommand }" 
              ToolTip="Apply all changes to the controller." /> 
            <Separator/> 
           </StackPanel> 
          </DockPanel> 
         </Grid> 
        </DataTemplate> 
        <DataTemplate DataType="{x:Type vms:LogViewModel}"> 
         <local:LogView /> 
        </DataTemplate> 
        <DataTemplate DataType="{x:Type vms:SignalStrengthViewModel}"> 
         <local:SignalStrengthView /> 
        </DataTemplate> 
       </TabControl.Resources> 

       <TabControl.ItemContainerStyle> 

        <Style TargetType="{x:Type TabItem}"> 
         <Setter Property="Header" Value="{Binding Name}" /> 
         <Setter Property="IsEnabled" Value="{Binding IsEnabled}" /> 
         <Setter Property="Header" Value="{Binding Name}" /> 
        </Style> 
       </TabControl.ItemContainerStyle> 


       <!--End Device List--> 
      </TabControl> 

回答

0

其實我不明白爲什麼不更新你的觀點,我想你必須告訴我你的背後的代碼。 什麼辦法可以嘗試:背後

  tabControl.UpdateLayout(); 

  tabControl.UpdateDefaultStyle(); 
+0

使用MVVM,所以沒有代碼。 – visc

+0

當然,我的意思是你的C#代碼或你的ViewModel。 –