本例移植的是WPF的DockPanel标签。
1、在Winform程序的解决方案下,右键添加组件(找到WPF下的UserControl进行添加),得到UserControl1.Xaml。
2、将待迁移的WPF内容复制到UserControl1.Xaml中,将DockPanel标签下的内容全部复制过去,同时xmlns:my所在行复制过去。例如
待迁移WPF内容如下:
<Window x:Class="WpfApplicationDemo.UserControlDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:WpfApplicationDemo.Control"
Title="UserControlDemo" Height="300" Width="300" Loaded="Window_Loaded">
<DockPanel>
<TextBlock Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="textBlock1" Text="下面是用户控件" VerticalAlignment="Top" />
<StackPanel Height=