2012-08-17 76 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">