2014-09-29 101 views
0

我正在使用infragistics tabcontrol控件。我的itemcontainer值基于对象属性。为了清楚我的意思,请看下面的代码片段。如何从tabitemex infragistics继承样式

WPF

<Window x:Class="DynamicTabControl.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:igWindows="http://infragistics.com/Windows" 
     xmlns:igDp="http://infragistics.com/DataPresenter" 
     xmlns:igThemes="http://infragistics.com/Themes" 
     Title="MainWindow" Height="450" Width="700"> 
    <Grid> 
     <igWindows:XamTabControl Name="xamTabCtrl" ItemsSource="{Binding Collection}" Theme="Metro"> 
       <igWindows:XamTabControl.ItemContainerStyle> 
        <Style TargetType="{x:Type igWindows:TabItemEx}" BasedOn="{x:Static igThemes:DataPresenterMetro.LabelPresenter}"> 
         <Setter Property="Header" Value="{Binding Path=Header}"/> 
        </Style> 
       </igWindows:XamTabControl.ItemContainerStyle> 
       <igWindows:XamTabControl.ContentTemplate> 
       <DataTemplate> 
        <igDp:XamDataGrid Theme="Metro" 
        DataSource="{Binding Logins}" IsGroupByAreaExpanded="False" GroupByAreaLocation="None" GroupByAreaMode="DefaultFieldLayoutOnly"/> 
       </DataTemplate> 
      </igWindows:XamTabControl.ContentTemplate> 
     </igWindows:XamTabControl> 
    </Grid> 
</Window> 

和部分类

public partial class MainWindow : Window 
    { 
     private ObservableCollection<Model> collection; 

     public ObservableCollection<Model> Collection 
     { 
      get { return collection; } 
     } 

     public MainWindow() 
     { 
      InitializeComponent(); 
      collection = new ObservableCollection<Model>() 
      { 
       new Model() { Header = "Tab1"}, 
       new Model() { Header = "Tab2"}, 
       new Model() { Header = "Tab3"}, 
       new Model() { Header = "Tab4"}, 
      }; 
      DataContext = this; 
      //xamTabCtrl.ItemsSource = collection; 
     } 
    } 

和模型

public class Model 
{ 
    private ObservableCollection<Login> _logins = new ObservableCollection<Login>() 
    { 
     new Login() { User = "User", Password = "Password"}, 
     new Login() { User = "User", Password = "Password"}, 
     new Login() { User = "User", Password = "Password"}, 
    }; 

    public string Header { get; set; } 

    public ObservableCollection<Login> Logins 
    { 
     get { return _logins; } 
    } 
} 

我编译时已经得到了错误

{"Can only base on a Style with target type that is base type 'TabItemEx'."} 
应用

谁可以继承infragistics主题的风​​格?

回答

0

我找到了。我找到了继承类。

<Style TargetType="{x:Type igWindows:TabItemEx}" BasedOn="{x:Static igThemes:PrimitivesMetro.TabItemEx}"> 
       <Setter Property="Header" Value="{Binding Path=Header}"/> 
      </Style>