I have this structure:
LightWindow.cs
namespace ScreenToGif.Controls.LightWindow
{
public class LightWindow : Window
{
static LightWindow()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(LightWindow), new FrameworkPropertyMetadata(typeof(LightWindow)));
}
//...
}
}
Recorder.xaml
<lightWindow:LightWindow x:Class="ScreenToGif.Windows.Recorder"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lightWindow="clr-namespace:ScreenToGif.Controls.LightWindow"
</lightWindow:LightWindow>
Generic.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lightWindow="clr-namespace:ScreenToGif.Controls.LightWindow">
<!-- Window style -->
<Style TargetType="{x:Type lightWindow:LightWindow}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type lightWindow:LightWindow}">
<!-- closing tags omitted -->
Problem:
The Recorder
window opens up invisible. In my test project (a dll with the custom window inside being used in another project), the window shows up correctly.
The only thing that shows up is the internal grid of the Recorder
window if I remove the OverrideMetadata
call (not what I want).