我想在WPF中的UserControl中使用Canvas但是
中没有任何Canvaspublic partial class UserControl1 : UserControl
我想将第二个userControl更改为Canvas
我该怎么办?
尊重
答案 0 :(得分:1)
Canvas
类位于程序集PresentationFramework.dll
中,因此您应该添加对此程序集的引用(msdn):
命名空间:System.Windows.Controls
程序集:PresentationFramework(在PresentationFramework.dll中)
XAML的XMLNS: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<强>更新强>
1)您应该在代码隐藏中更改此值:
public partial class UserControl1 : Canvas
{
public UserControl1()
{
InitializeComponent();
}
}
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>