Hi
I have a xamTabControl whose ItemsSource is bound to an observable collection of viewmodels and need to have editable tab headers. I am using the example found here:
http://blogs.infragistics.com/blogs/alex_fidanov/archive/2009/10/01/how-to-rename-the-tabitems-of-the-xamtabcontrol-runtime-like-excel.aspx
But the problem is that instead of the Header property, the object type ToString() is being displayed in the tab header. Any idea what I might have done wrong and how I can get the actual header property displayed?
In my view I have the following (along with the TabItemEx style specified above):
<ig:XamTabControl ItemsSource="{Binding WorkspaceTabNames}" TabStripPlacement="Bottom" ContentTemplate="{StaticResource tabContentDataTemplate}" Theme="Office2k7Blue">
Tried to modify the style of TabItemEx slightly to this:
<igEditors:XamTextEditor PreviewMouseLeftButtonDown="tbEdit_PreviewMouseDoubleClick" BorderThickness="0" Background="Transparent" EditModeStarting="tbEdit_EditModeStarting" EditModeEnding="tbEdit_EditModeEnding" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Header, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
In the view model of my view containing the tab control:
public ObservableCollection<WorkspaceViewModel> WorkspaceTabNames{ get { return new ObservableCollection<WorkspaceViewModel> { new WorkspaceViewModel("Tab 1", "Content 1"), new WorkspaceViewModel("Tab 2", "Content 2"), new WorkspaceViewModel("Tab x", "Content x") }; }}
And finally, the view model itself:
public class WorkspaceViewModel: INotifyPropertyChanged{ public string Header { get; private set; } public string Content { get; private set; }
public WorkspaceViewModel(string header, string content) { Header = header; Content = content; }
#region INotifyPropertyChanged Implementation ... #endregion}