The problem is this:
I have customized a control that can be reversed in two states, with the following resource file:
<resourcedictionary xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= "http ://schemas.microsoft.com/winfx/2006/xaml "xmlns:local=" Clr-namespace:musicmian "&G
T <style targettype= "{x:type Local:nativecontainer}" > <setter property= "istabstop" Value= "False" ></Se tter> <setter property= "Focusable" value= "False" ></Setter> <setter property= "Template" &G
T
<Setter.Value> <controltemplate targettype= "{x:type Local:nativecontainer}" > <Grid> <VisualStateManager.VisualStateGroups> <visua
Lstategroup name= "Viewstates" > <visualstate name= "Contentview" > <Storyboard> <doubleanimation storyboard.targetname= "T OoLtipborder "storyboard.targetproperty=" Opacity "duration=" 0 "to=
"0"/> </Storyboard> </VisualState> <visualstate x:name= "Tootipview" &
Gt
<Storyboard> <doubleanimation storyboard.targetname= "Contentborder"
Storyboard.targetproperty= "Opacity" duration= "0" to= "0"
/> </Storyboard> </VisualState> </VisualStateGroup> </vis
ualstatemanager.visualstategroups> <border name= "Contentborder" > <contentpresenter verticalalignment= "Stretch" DataCo ntext= "{TemplateBinding DataContext}" horizontalalignment= "Stretch" content=
"{TemplateBinding Contentview}" ></ContentPresenter> </Border>
<border name= "Tooltipborder" > <contentpresenter verticalalignment= "Stretch"
datacontext= "{TemplateBinding DataContext}"
Horizontalalignment= "Stretch" content= "{TemplateBinding Tooltipview}" ></ContentPresenter> </Border> </Grid> </ControlTemplate> </sette r.value> </Setter> </Style> </ResourceDictionary>
The function code is as follows:
public class Nativecontainer:control {static Nativecontainer () {Defaultstylekeypropert
Y.overridemetadata (typeof (Nativecontainer), New Frameworkpropertymetadata (typeof (Nativecontainer))); Isfilpedproperty = Dependencyproperty.register ("isfilped", typeof (BOOL), typeof (Nativecontainer), new
Frameworkpropertymetadata (false,new propertychangedcallback (isfilpedchanged)));
Contentviewproperty = Dependencyproperty.register ("Contentview", typeof (Object), typeof (Nativecontainer));
Tooltipviewproperty = Dependencyproperty.register ("Tooltipview", typeof (Object), typeof (Nativecontainer));
} private static void Isfilpedchanged (DependencyObject D, DependencyPropertyChangedEventArgs e) {
Nativecontainer NC = (nativecontainer) D; NC.
Changedvisualstate (FALSE); } private void Changedvisualstate (bool p) {if (isfilped) {Visual StatEmanager.gotostate (This, "Contentview", p);
} else {visualstatemanager.gotostate (this, "Tootipview", p);
} UIElement CView = Contentview as UIElement; if (CView! = null) {if (isfilped) {cview.visibility = Vi Sibility.
Visible;
} else {cview.visibility = Visibility.hidden;
}} UIElement TView = Tooltipview as UIElement; if (TView! = null) {if (isfilped) {tview.visibility = Vi Sibility.
Hidden;
} else {tview.visibility = visibility.visible;
}}} public static readonly DependencyProperty Isfilpedproperty; public static readonly DependeNcyproperty Contentviewproperty;
public static readonly DependencyProperty Tooltipviewproperty;
public bool Isfilped {get {return (bool) GetValue (Isfilpedproperty);}
set {SetValue (Isfilpedproperty, value);}
Public object Contentview {get {return (object) GetValue (Contentviewproperty);}
set {SetValue (Contentviewproperty, value);}
Public object Tooltipview {get {return (object) GetValue (Tooltipviewproperty);}
set {SetValue (Tooltipviewproperty, value);} } public override void OnApplyTemplate () {base.
OnApplyTemplate ();
Changedvisualstate (FALSE); }
}
The code is simple and does not explain.
The problem I'm having now is that I put two of these custom controls into the two tabitem of TabControl, the same data source binding method (Contentview in the custom control), the first one to bind to the data, and the second one to bind to the data. Which hero can help me solve this problem, express my thanks ...