0

I have this structure:

enter image description here

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).

daniele3004
  • 13,072
  • 12
  • 67
  • 75
Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79

1 Answers1

0

How to make to work:

enter image description here

Move the Themes resource to the root folder of the project.

Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79
  • 1
    That't pretty important and known fact about `Generic.xaml` file, read about it here http://stackoverflow.com/questions/1228875/what-is-so-special-about-generic-xaml – Ondrej Janacek Nov 22 '14 at 08:26