आप XAML कोड यह आत्म वारिस नहीं कर सकते लेकिन codebehind का एक अमूर्त वर्ग बनाते समय, आप कोड में पीछे संपादित करने के लिए, एक व्युत्पन्न वर्ग वस्तु से की अनुमति देगा
Xaml कोड:।। {Window1.xaml }
<Window
x:Class="WPFSamples.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="auto" Width="256" Title="WPF Sameples">
<Grid>
<Button x:Name="Button1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Click Me"/>
</Grid>
</Window>
codebehind: {} Window1.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFSamples
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public abstract partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
}
}
व्युत्पन्न वर्ग: {} DisabledButtonWindow.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WPFSamples
{
public sealed class DisabledButtonWindow : Window1
{
public DisabledButtonWindow()
{
Button1.IsEnabled = false;
}
}
}
हालांकि आप स्वयं wpf स्रोत से प्राप्त नहीं कर सकते हैं, तो आप इस "विंडो 1" नियंत्रण को अन्य सभी व्युत्पन्न नियंत्रणों के लिए टेम्पलेट के रूप में उपयोग करने में सक्षम हैं।
विजुअल विरासत के साथ डब्ल्यूपीएफ वर्कअराउंड के लिए देखें: http://svetoslavsavov.blogspot.gr/2009/09/user-control-inheritance-in-wpf.html या पूर्वजों में स्पष्ट रूप से जीयूआई को परिभाषित करने के लिए http: // देखें support.microsoft.com/kb/957231 –