2016-02-23 74 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。 –