2012-08-17 73 views
0

我有一个wormControl类,它应该从MyUserControl继承,但是在构建解决方案时,wormControl将从UserControl继承。 无论如何,我希望它从MyUserControl继承。如何实现它?防止继承UserControl

这里是我的用户控件XAML文件:

<UserControl 
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:System="clr-namespace:System;assembly=mscorlib" 
mc:Ignorable="d" 
x:Class="FishGameAnimations.wormControl" 
d:DesignWidth="575" d:DesignHeight="339"> 
/* ...other stuff... */ 
</UserControl> 
+2

继承是在你的wormControl后面的代码中处理的。请张贴此代码并澄清您的问题。 – 2012-08-17 09:49:46

+0

尝试[从WPF中的UserControl继承](http://stackoverflow.com/questions/269106/inheriting-from-a-usercontrol-in-wpf)。 – Rafal 2012-08-17 09:55:58

+0

@Michael你解决了你的问题吗? – Artiom 2012-08-18 04:20:00

回答

0

正如有人说你的基地控制必须是无XAML。所有的设计都应该从代码的后面构建。看看Rafal给出的链接。 一个示例如何设置基类的控制

<Controls:MyUserControl x:Class="Termo.Win.Controls.ChildControl" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:Controls="clr-namespace:Namespace.MyUserControl">