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}
Hello Prasanti,
Could you please send us an isolated sample project, where this is reproduced, so we could be able to investigate it further for you?
Looking forward for your reply.
Dear Stefan,
Thankyou for your response. I have tried IsExpandedMemberPath and IsSelectedMemberPath as it is stated in the example.
But I could restore only the expanded structure of the XamDataTree but not the selected node of the XamDataTree, on changing the tabs
of XamTabControl. Please help me out.
Thankyou,
Prasanti.
Thank you for your post. I have been looking into it and I can say that when you switch the tabs, the controls inside them unload and load and this is why the expanded state is not preserved. The thing you can do is add an IsExpanded Property to your data and set it to the IsSelectedMemberPath property to the XamDataTree. Here a similar topic is already discussed:
http://ko.infragistics.com/community/forums/p/90631/447829.aspx
Hi Stefan,
I have a problem in using XamTabControl. I have a XamTabControl whose ItemSource is bound to ObservableCollection of viewmodels.
The View contains a XamDataTree. So I could display the XamDataTree on all the opened tabs of XamTabControl.
But I state of the XamDataTree(Expanded and selected nodes) is not being restored when I switch between tabitems.
The XamDataTree is being collapsed as I traverse between various tabs. Could you please help me in getting a work around for this issue.
thankyou,
Prasanti
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.