diff --git a/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.cs b/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.cs index 145ec2008..a842d7402 100644 --- a/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.cs +++ b/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.cs @@ -25,6 +25,7 @@ public partial class MyControl : UserControl public MyControl() { InitializeComponent(); + InitializeDefaultValues(); } public FontWeight MyControlFontWeight @@ -109,15 +110,15 @@ public SolidColorBrush MyControlForeground public event MyControlEventHandler OnButtonClick; - private void Init(object sender, EventArgs e) + private void InitializeDefaultValues() { //They all have the same style, so use nameLabel to set initial values. _fontWeight = nameLabel.FontWeight; _fontSize = nameLabel.FontSize; _fontFamily = nameLabel.FontFamily; _fontStyle = nameLabel.FontStyle; - _foreground = (SolidColorBrush) nameLabel.Foreground; - _background = (SolidColorBrush) rootElement.Background; + _foreground = (SolidColorBrush)nameLabel.Foreground; + _background = (SolidColorBrush)rootElement.Background; } private void ButtonClicked(object sender, RoutedEventArgs e) diff --git a/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.xaml b/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.xaml index 04c8bbf4f..cf3c37863 100644 --- a/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.xaml +++ b/Migration and Interoperability/WindowsFormsHostingWpfControl/WPFControls/MyControl.xaml @@ -4,14 +4,12 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:WPFControls" - mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + mc:Ignorable="d"> + Name="rootElement">