public void SetFileTabDefinition(FileTabDefinition fileTabDefinition) { this.DataContext = fileTabDefinition; if (fileTabDefinition.IsSeparator) { this.Content = new Separator(); this.IsEnabled = false; } else { this.SetBinding(TabItem.HeaderProperty, new Binding { Source = fileTabDefinition, Path = new PropertyPath(FileTabDefinition.HeaderProperty) }); var presenter = new ContentPresenter(); presenter.SetBinding(ContentPresenter.ContentTemplateProperty, new Binding { Source = fileTabDefinition, Path = new PropertyPath(FileTabDefinition.ContentTemplateProperty) }); this.Content = presenter; this.command = fileTabDefinition.Command as RoutedCommand; if (fileTabDefinition.Command != null) { fileTabDefinition.Command.CanExecuteChanged += OnCommandCanExecuteChanged; this.IsEnabled = this.command == null?fileTabDefinition.Command.CanExecute(fileTabDefinition.CommandParameter) : this.command.CanExecute(fileTabDefinition.CommandParameter, fileTabDefinition.CommandTarget); } } }
public void SetFileTabDefinition(FileTabDefinition fileTabDefinition) { this.DataContext = fileTabDefinition; if (fileTabDefinition.IsSeparator) { this.Content = new Separator(); this.IsEnabled = false; } else { this.SetBinding(TabItem.HeaderProperty, new Binding { Source = fileTabDefinition, Path = new PropertyPath(FileTabDefinition.HeaderProperty) }); var presenter = new ContentPresenter(); presenter.SetBinding(ContentPresenter.ContentTemplateProperty, new Binding { Source = fileTabDefinition, Path = new PropertyPath(FileTabDefinition.ContentTemplateProperty) }); this.Content = presenter; this.command = fileTabDefinition.Command as RoutedCommand; if (fileTabDefinition.Command != null) { fileTabDefinition.Command.CanExecuteChanged += OnCommandCanExecuteChanged; this.IsEnabled = this.command == null ? fileTabDefinition.Command.CanExecute(fileTabDefinition.CommandParameter) : this.command.CanExecute(fileTabDefinition.CommandParameter, fileTabDefinition.CommandTarget); } } }