Sanırım sorduğun şey, ResourceDictionary için arka plan kod dosyası istiyorsun. Bunu kesinlikle yapabilirsiniz! Aslında, bunu bir Pencere ile aynı şekilde yaparsınız:
MyResourceDictionary adlı bir ResourceDictionary'niz olduğunu varsayalım. MyResourceDictionary.xaml dosyanızda, x: Class özniteliğini kök öğeye şu şekilde yerleştirin:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyCompany.MyProject.MyResourceDictionary"
x:ClassModifier="public">
Ardından, aşağıdaki bildirimle MyResourceDictionary.xaml.cs adlı dosyanın arkasında bir kod oluşturun:
namespace MyCompany.MyProject
{
partial class MyResourceDictionary : ResourceDictionary
{
public MyResourceDictionary()
{
InitializeComponent();
}
...
}
}
Ve bitirdiniz. Kodun arkasına dilediğinizi koyabilirsiniz: yöntemler, özellikler ve olay işleyicileri.
== Windows 10 uygulamaları için güncelleme ==
Ve UWP ile oynuyorsanız, dikkat etmeniz gereken bir şey daha var:
<Application x:Class="SampleProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:rd="using:MyCompany.MyProject">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<rd:MyResourceDictionary />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>