WPF 用户控件(UserControl)

WPF 用户控件(UserControl)

简介

"用户控件"继承自UserControl,而UserControl继承自ContentControl,也就是内容控件UserControl和Window是一个层次上的,都有xaml和cs文件

流程

创建用户控件

写好用户控件

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"

mc:Ignorable="d"

d:DesignHeight="300" d:DesignWidth="300">

用户控件也可以套用用户控件,组成更复杂的界面

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:userControlDemo="clr-namespace:WpfDemo.UserControlDemo"

mc:Ignorable="d"

d:DesignHeight="300" d:DesignWidth="300">

窗体引用用户控件

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

xmlns:userControlDemo="clr-namespace:WpfDemo.UserControlDemo"

mc:Ignorable="d"

Title="UseUserControlWindow" Height="600" Width="400">

示例代码

https://github.com/zLulus/NotePractice/tree/dev3/WPF/WpfDemo/UserControlDemo

相关推荐

365平台赌博 饥饿的鲨鱼进化大尾虎鲨好吗 大尾虎鲨获取攻略
mobile288-365 努比亚手机苏宁自营旗舰店

努比亚手机苏宁自营旗舰店

📅 08-30 👁️ 6251
365体育平台真假怎么分 原车氙气灯型号欧司朗D8s想升级灯光亮度,有什么方法升级?