I am trying to access a named grid inside the default template for a custom control from code. But it seems that the template for the control is zero, even after calling ApplyTemplate ().
Is this not possible in control? Here is the code:
Generic.xaml: ... <ControlTemplate TargetType="{x:Type local:TimeTableControl}"> <Grid Name="ContentGrid"> </Grid> </ControlTemplate> ... TimeTableControl.cs: public TimeTableControl() { ApplyTemplate(); contentGrid = (Grid)(Template.FindName("ContentGrid", this));
source share