c# - ContentControl.Template is null even it is in XAML -


Perhaps the title is confusing you, but the problem is strictly here: I have the XAML file Is ControlTemplate for MyType (from ContentControl ). And in that template, I have set its DataContext as the following:

  DataContext = "{binding relative source = {relative servus templated} Paint}} "  

and when I want to get the MyType from DataContext , it displays the tap for the first time After clicking on (it is rectangular in the window) this object changes which I want I searched all the things, all the events that I am doing in the LeftButtonDown do not have any ApplyTemplate (), UpdateLayout () methods Even I have these methods Does not help to call. What to do? PS is the datacontext of this item parent , I can send a parameter but there should be another solution in it

this part of XAML which template is located:

  style target type = "{x: type: connector}" & gt; & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: Type: Connector}" & gt; & Lt; Grid name = "grid" datacentext = "{binding relative souras = {relative souras templated}}" & gt; & Lt; Border border border = "{binding relative sours = {relative mode = templated pent}, path = border brush}" X: name = "border" borderTechnication = "2" background = "transparent" & gt; & Lt; Image source = "/ diagramdisignerager; component / resource / 1337238611_port.png" /> & Lt; / Border & gt; & Lt; Fill Rectangle = "Transparent" margin = "- 2" /> & lt; / Grid & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;   

And this is where I get the datacontext:

  Public Designer Item Paintedisizer Itam // {Get (if parentDesignerItem == null) {ParentDesignerItem = this designer item as DIITECONTEX; // if (parentDesignerItem == faucet) parentDesignerItem = (this.Template.FindName ("grid", as this grid). Datacontext as DesignerItem;} Return Parental Designer Item;} Set {parentDesignerItem = value; }}   

I should say that this is the style in XAML which is the style of Designer item .

The problem is in my algorithm PS I SQL , and with 2x more connectors Code> and when I want to access it gives me these empty objects.

Comments