1.创建WinForm窗体以及WPF用户控件
1.1创建WinForm窗体
2.创建WPF用户控件
3.先选中工程文件(WPF用户控件所在的工程)生成一下,这样才能在工具箱中看见新加的WPF用户控件
然后将WPF用户控件拖入WinForm窗体中(WinForm与WPF互相操作需要在WinForm中添加ElementHost控件,VS2013添加
WPF用户控件是会自动添加ElementHost控件)
2.WPF开始布局控件
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DemoCollection" x:Class="DemoCollection.WPFUserControl2"
mc:Ignorable="d"
d:DesignHeight="464" d:DesignWidth="907">
<Viewbox x:Name="Viewbox" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Stretch="Fill">
<StackPanel x:Name="StackPanel1" >
<Slider x:Name="Slider1" Width="113" Panel.ZIndex="11" ValueChanged="Slider1_ValueChanged" Margin="700,0,0,0"/>
<ScrollViewer x:Name="ScrollViewer1" Height="464" Width