Jump to content

Recommended Posts

Posted

Hi !

 

I have a problem with two custom controls that I want to make :

  • *the first one is a Page derived controls, which contains a TabControl.
  • the second one is a HeaderedContentControl, made to be contained by the first one.

The purpose is to navigate to a page and directly display a tab.

 

So, the navigation to a tab is not a problem. The problem is to have different pages with different tabs... :(

 

I have made this classes (I just copy relevant code) :

 

[ContentProperty("MyTabs")]

public class MyPage : Page

{

*** public List MyTabs

*** {

******* get { return (List)GetValue(MyTabsProperty); }

******* set { SetValue(MyTabsProperty, value); }

*** }

*** public static readonly DependencyProperty MyTabsProperty =

******* DependencyProperty.Register("MyTabs", typeof(List), typeof(FrameworkElement), new FrameworkPropertyMetadata(new List()));

 

*** static MyPage()

*** {

******* DefaultStyleKeyProperty.OverrideMetadata(typeof(MyPage), new FrameworkPropertyMetadata(typeof(MyPage)));

*** }

 

*** public MyPage() : base() { }

 

*** public override void OnApplyTemplate()

*** {

******* base.OnApplyTemplate();

******* TabControl tabControl = GetTemplateChild("PART_TabControl") as TabControl;

******* if (tabControl != null)

******* {

*********** Binding tabsBinding = new Binding();

*********** tabsBinding.Source = this.MyTabs;

*********** tabControl.SetBinding(TabControl.ItemsSourceProperty, tabsBinding);

******* }

*** }

}

 

 

public class MyTab : HeaderedContentControl

{

*** static MyTab()

*** {

******* //DefaultStyleKeyProperty.OverrideMetadata(typeof(MyTab), new FrameworkPropertyMetadata(typeof(MyTab)));

*** }

*** public void Reset()

*** {

******* //...

*** }

*** public void Compute()

*** {

******* //...

*** }

}

 

 

 

And, when I use this classes like this :

 

 

***

*******

*******

***

 

 

 

*******

*******

*******

*******

 

 

 

*******

*******

*******

 

 

 

... my two frames contain the all seven tabs.

 

Actually, when I add a tab in MyPage1 or MyPage2, the tab is added in the MyTabs property in MyPage...

 

I don't know how to tell WPF that the MyTabs property is different for each derived class.

 

Somebody have an answer ?

 

 

 

 

More...

 

View All Our Microsoft Related Feeds

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...