0

Inside this custom control's control template

<ControlTemplate TargetType="{x:Type local:CustomLineGraph}">
         <StackPanel Orientation="Vertical">               
              <Canvas x:name"myCanvas"></Canvas>
              <Border Background="#FF0000"
                                BorderBrush="Red"
                                BorderThickness="5">

              </Border>
          </StackPanel>
 </ControlTemplate>

How can I access the Canvas from the class

 public class CustomLineGraph : Control
        {
           myCanvas.AddChild(obj);
        }

x:name doesn't work.

ozgur
  • 2,549
  • 4
  • 25
  • 40

1 Answers1

0

The following should give you the Canvas Element

(this.Template.LoadContent() as FrameworkElement).FindName("myCanvas") as Canvas
shat90
  • 405
  • 3
  • 8