public override void OnApplyTemplate() { base.OnApplyTemplate(); this.renderTargetControl = this.Template.FindName("PART_RenderTargetControl", this) as Image; this.ogreImage = this.Template.FindName("PART_OgreImage", this) as OgreImage; this.overlayTextBlock = this.Template.FindName("PART_OverlayTextBlock", this) as TextBlock; // Events require ogreImage. this.SizeChanged += (s, e) => { this.ogreImage.ViewportSize = e.NewSize; }; this.ogreImage.Initialized += (s, e) => { this.initialized = true; OverlayText = "Please load a Scene File..."; if (OgreInitialized != null) OgreInitialized(s, e); }; this.ogreImage.ResourceLoadItemProgress += (s, e) => { if (ResourceLoadItemProgress != null) ResourceLoadItemProgress(s, e); }; this.ogreImage.FrameRate = (MogitorSettings.Instance.UseWpfDisplaySurface == true)? (int?)null : MogitorSettings.Instance.FrameRate; this.ogreImage.InitOgreAsync(); }