我做了所謂的SmartTabItem一個自定義的控制,目前只是默認的實現:爲什麼我的TabItem自定義控件沒有出現在的TabControl
using System.Windows;
using System.Windows.Controls;
namespace TestControl.Controls
{
public class SmartTabItem : TabItem
{
static SmartTabItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(SmartTabItem), new FrameworkPropertyMetadata(typeof(SmartTabItem)));
}
}
}
我包括在我的的TabControl這樣的:
<Window x:Class="TestControl.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:TestControl.Controls"
Title="Window1" Height="300" Width="300">
<DockPanel Margin="10">
<TabControl>
<controls:SmartTabItem Header="One">content of one</controls:SmartTabItem>
<TabItem Header="Two">content of two</TabItem>
<TabItem Header="Three">content of three</TabItem>
</TabControl>
</DockPanel>
</Window>
但是隻顯示標籤「Two」和「Three」。 爲什麼SmartTabItem不在TabControl中顯示,如果它繼承自TabItem?
我只是有完全相同的問題。感謝您提出問題。 – jjnguy 2009-10-24 01:37:23