[英]How to Use Canvas in UserControl in WPF
i want to use Canvas in UserControl in WPF but there isn't any Canvas in 我想在WPF中的UserControl中使用Canvas,但其中没有任何Canvas
public partial class UserControl1 : UserControl
i want to change this second userControl to Canvas 我想将第二个userControl更改为Canvas
what should i do? 我该怎么办?
With Respect 尊重地
Canvas
class is in the assembly PresentationFramework.dll
, so you should add reference to this assembly ( msdn ): Canvas
类位于程序集PresentationFramework.dll
,因此您应添加对此程序集( msdn )的引用:
Namespace: System.Windows.Controls
命名空间:System.Windows.Controls
Assembly: PresentationFramework (in PresentationFramework.dll)
程序集:PresentationFramework(在PresentationFramework.dll中)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation , http://schemas.microsoft.com/netfx/2007/xaml/presentation
XAML的XMLNS: http : //schemas.microsoft.com/winfx/2006/xaml/presentation,http : //schemas.microsoft.com/netfx/2007/xaml/presentation
UPDATE 更新
1) You should change this value in code-behind: 1)您应该在后面的代码中更改此值:
public partial class UserControl1 : Canvas
{
public UserControl1()
{
InitializeComponent();
}
}
2) You should change it in XAML: 2)您应该在XAML中进行更改:
<Canvas x:Class="MyApp.UserControl1"
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">
</Canvas>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.