NewsBot
1
Hi !
I have a problem with two custom controls that I want to make :
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
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.
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