コード例 #1
0
        private void UseHelperMethod()
        {
            var myHostControl = new WindowsXamlHost();

            myHostControl.Dock = DockStyle.Fill;

            // Use helper method to create a UWP control instance.
            uwpButton =
                UWPTypeFactory.CreateXamlContentByType("Windows.UI.Xaml.Controls.Button")
                as Windows.UI.Xaml.Controls.Button;

            // Initialize UWP control.
            uwpButton.Name = "button1";
            uwpButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
            uwpButton.VerticalAlignment   = Windows.UI.Xaml.VerticalAlignment.Stretch;
            uwpButton.Background          = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red);
            uwpButton.Click += delegate { uwpButton.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Blue); };

            // initialize the Windows XAML host control.
            myHostControl.Name  = "myWindowsXamlHostControl";
            myHostControl.Child = uwpButton;

            // Make the UWP control appear in the UI.
            this.Controls.Add(myHostControl);
        }
コード例 #2
0
 protected WindowsXamlHostBase(string typeName)
     : this()
 {
     if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
     {
         ChildInternal = UWPTypeFactory.CreateXamlContentByType(typeName);
         ChildInternal.SetWrapper(this);
     }
 }
コード例 #3
0
 protected WindowsXamlHostBase(string typeName)
     : this()
 {
     if (!DesignMode)
     {
         ChildInternal = UWPTypeFactory.CreateXamlContentByType(typeName);
         ChildInternal.SetWrapper(this);
     }
 }
コード例 #4
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            this.ChildInternal = UWPTypeFactory.CreateXamlContentByType("Windows.UI.Xaml.Controls.CalendarView");

            SetContent();

            Windows.UI.Xaml.Controls.CalendarView calendarView = this.ChildInternal as Windows.UI.Xaml.Controls.CalendarView;
            calendarView.SelectedDatesChanged += CalendarView_SelectedDatesChanged;
        }
コード例 #5
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            // Rectangle's HorizontalAlignment and VerticalAlignment properties default to Stretch.
            // The control will fill all space available in the DesktopWindowXamlSource window.
            this.ChildInternal = UWPTypeFactory.CreateXamlContentByType("Windows.UI.Xaml.Shapes.Rectangle");

            // Set DesktopWindowXamlSource
            SetContent();

            global::Windows.UI.Xaml.Shapes.Rectangle rectangle = this.ChildInternal as global::Windows.UI.Xaml.Shapes.Rectangle;

            // Properties set in markup need to be re-applied in OnInitialized
            Fill = fill;
        }
コード例 #6
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            this.ChildInternal = UWPTypeFactory.CreateXamlContentByType("Windows.UI.Xaml.Controls.Button");

            // Make button expand to the size of its host control
            global::Windows.UI.Xaml.FrameworkElement frameworkElement = this.ChildInternal as global::Windows.UI.Xaml.FrameworkElement;
            frameworkElement.SizeChanged        += FrameworkElement_SizeChanged;
            frameworkElement.HorizontalAlignment = global::Windows.UI.Xaml.HorizontalAlignment.Stretch;
            frameworkElement.VerticalAlignment   = global::Windows.UI.Xaml.VerticalAlignment.Stretch;

            // Set DesktopWindowXamlSource
            SetContent();

            // Properties set in markup need to be re-applied in OnInitialized.
            Background = background;
            Content    = content;
        }
コード例 #7
0
 public WindowsXamlHostBaseExt(string typeName)
 {
     ChildInternal = UWPTypeFactory.CreateXamlContentByType(typeName);
     ChildInternal.SetWrapper(this);
 }
コード例 #8
0
 internal virtual void InitializeElement()
 {
     XamlElement         = UWPTypeFactory.CreateXamlContentByType(initialTypeName);
     _xamlSource.Content = XamlElement;
     XamlElement.SetWrapper(this);
 }