This is a migrated thread and some comments may be shown as answers.

WPF - close teleric tabItem.

1 Answer 109 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Vitas Vitauskas
Top achievements
Rank 1
Vitas Vitauskas asked on 22 Dec 2009, 08:00 AM
Hello, I organiza my windows like tabItems in tab controls. when i click on menu item:

        private void PaieskaTab_Click(object sender, Telerik.Windows.RadRoutedEventArgs e) 
        { 
            RadTabItem tabItem = new RadTabItem(); 
            ListTemplate lst = new ListTemplate(); 
            lst.tabWindow = tabItem
            tabItem.Content = lst
            tabItem.Header = "Paieskos langas"
            tabItem.Name = "tabPaieskosTestas"
            tabControlR.Items.Add(tabItem); 
        } 
ListTemplate is a user control. In List template is a button "Close". Now when i click this button, i need that this tab,whitch contains this user control, would close. I try code from other forum in telerik:
            var tabItem = tabWindow as RadTabItem; 
 
            var parentItemsControl = Telerik.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(tabItem); 
 
            parentItemsControl.Items.Remove(tabItem);  
But his code shows error:
Error 23 The type or namespace name 'ItemsControl' does not exist in the namespace 'Telerik.Windows.Controls' (are you missing an assembly reference?) D:\!_Projects\Teleric_EmptyProject WPF\XSoftArt.WPFengine\XSoftArt.WPFengine\BaseClasses\ListTemplate.xaml.cs 1102 63 XSoftArt.WPFengine
Its this becouse that code is for Silverlight..?How i must change it to get working..?

1 Answer, 1 is accepted

Sort by
0
Accepted
Valentin.Stoychev
Telerik team
answered on 22 Dec 2009, 08:31 AM
Hello Vitas Vitauskas,

Yes - this is because you use a Silverlight code in WPF. You need to use System.Windows.Controls.ItemsControl instead.

Check this help article:
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemscontrolfromitemcontainer.aspx

Regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TabControl
Asked by
Vitas Vitauskas
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Share this question
or