System.Windows.Controls.Control.ApplyTemplate C# (CSharp) Method

ApplyTemplate() public method

public ApplyTemplate ( ) : bool
return bool
		public new bool ApplyTemplate()
		{
			return base.ApplyTemplate ();
		}
		

Usage Example

        public void BindingExtensionTemplatedParentTest()
        {
            string text = @"
            <ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' x:Name='root'>
                <FrameworkElement x:Name='child' Width='{TemplateBinding FrameworkElement.Height}'/>
            </ControlTemplate>";

            ControlTemplate template = XamlLoader.Load(XamlParser.Parse(text)) as ControlTemplate;

            Control control = new Control();

            control.Template = template;
            control.ApplyTemplate();

            FrameworkElement child = NameScope.GetTemplateNameScope(control).FindName("child") as FrameworkElement;

            Assert.AreEqual(control, child.TemplatedParent);

            control.Height = 100;
            Assert.AreEqual(100, child.Width);
        }
All Usage Examples Of System.Windows.Controls.Control::ApplyTemplate