none
Cannot find a Resource with the Name/Key ChildWindowStyleLawBot

    Question

  • Hi,

    I am trying to style a Child Window control in Silverlight 4 but am getting a strange error when the InitializeComponent() method in code behind is hit.

    Cannot find a Resource with the Name/Key ChildWindowStyleLawBot

    For some reason, my Child Window cannot see any of the styles in the App.xaml. 

    public ReadCodeChildWindow(Code code)
      {
              // ERROR HAPPENS HERE
              InitializeComponent();
              _code = code;
     }

    However, I have added the style and resources to App.xaml Application.Resources as follows:

    <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Brushes.xaml"/>
                    <ResourceDictionary Source="Assets/Fonts.xaml"/>
                    <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Assets/SdkStyles.xaml"/>
                </ResourceDictionary.MergedDictionaries>
           

    <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black"  Offset="0" />
                <GradientStop Color="#FF6D7C96" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="BrushGridUnderChrome"  EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#D2000F2D" Offset="1" />
                <GradientStop Color="#43FFFFFF" />
                <GradientStop Color="#E87F8796" Offset="0.5" />
     </LinearGradientBrush>

     <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF6C7B95" Offset="0" />
                    <GradientStop Color="#FF000F2D" Offset="1" />
                    <GradientStop Color="#FF000F2D" Offset="0.15" />
                    <GradientStop Color="#FF000F2D"  Offset="0.15" />
      </LinearGradientBrush>


    <Style x:Key="ChildWindowStyleLawBot" TargetType="sdk:ChildWindow">
                <Setter Property="IsTabStop"  Value="false" />
                <Setter Property="TabNavigation"

     .................
    ....................

    Child Window Xaml that reference the resouce
    -------------------------------------------------------------

    <controls:ChildWindow x:Class="CodeGeneratorModule.Views.ReadCodeChildWindow"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
               Width="600" Height="500"
               Title="Generated Code" Style="{StaticResource ChildWindowStyleLawBot}" FontFamily="Verdana">

        <Grid x:Name="LayoutRoot" Margin="2" Background="{StaticResource ChildWindowLayoutRootBackgroundBrush}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
    ............
     ..........

    Please can someone help me to sort this out?

    Cheers

     

    Thursday, May 19, 2011 6:33 AM

Answers

  • At the root of "[Something].Resources" (in your case "Application.Resources") there's only
    one "<ResourceDictionary>" is allowed, and if you specified it, "<Application.Resources>"
    should contain nothing else, but just one "<ResourceDictionary>".
    In the markup you posted, you're putting other resources (LinearGradientBrush, Style, etc.) at the root
    of Application.Resources.
    And ther is one more thing:
    If you're using "<ResourceDictionary.MergedDictionaries>" of "<ResourceDictionary>", it could not contain
    any other resources.

    Let's get back to your markup.
    You have to put all your resources, delcared in "App.xaml" into "<ResourceDictionary>", and put it
    into "<ResourceDictionary.MergedDictionaries>".
    Your markup should look like this:


    <Application x:Class="CodeGeneratorModule.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:System="clr-namespace:System;assembly=mscorlib"
                
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                         >
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Brushes.xaml"/>
                    <ResourceDictionary Source="Assets/Fonts.xaml"/>
                    <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Assets/SdkStyles.xaml"/>


    <ResourceDictionary>
            <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="Black"
        Offset="0" />
                <GradientStop Color="#FF6D7C96"
        Offset="1" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="BrushGridUnderChrome"
       EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="#D2000F2D"
        Offset="1" />
                <GradientStop Color="#43FFFFFF" />
                <GradientStop Color="#E87F8796"
        Offset="0.5" />
            </LinearGradientBrush>
                <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                    <GradientStop Color="#FF6C7B95"
        Offset="0" />
                    <GradientStop Color="#FF000F2D"
        Offset="1" />
                    <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                    <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                </LinearGradientBrush>

                <Style x:Key="ChildWindowStyleLawBot" TargetType="sdk:ChildWindow">
                <Setter Property="IsTabStop"
        Value="false" />
                <Setter Property="TabNavigation"
        Value="Cycle" />
                <Setter Property="HorizontalAlignment"
        Value="Center" />
                <Setter Property="VerticalAlignment"
        Value="Center" />
                <Setter Property="HorizontalContentAlignment"
        Value="Stretch" />
                <Setter Property="VerticalContentAlignment"
        Value="Stretch" />
                <Setter Property="BorderThickness"
        Value="1" />
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1"
          StartPoint="0.5,0">
                            <GradientStop Color="#FFA3AEB9"
           Offset="0" />
                            <GradientStop Color="#FF8399A9"
           Offset="0.375" />
                            <GradientStop Color="#FF718597"
           Offset="0.375" />
                            <GradientStop Color="#FF617584"
           Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="OverlayBrush"
        Value="#7F000000" />
                <Setter Property="OverlayOpacity"
        Value="1" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="sdk:ChildWindow">
                            <Grid x:Name="Root">
                                <Grid.Resources>
                                    <Style x:Key="ButtonStyle"
             TargetType="Button">
                                        <Setter Property="Background"
              Value="#FF1F3B53" />
                                        <Setter Property="Foreground"
              Value="#FF000000" />
                                        <Setter Property="Padding"
              Value="3" />
                                        <Setter Property="BorderThickness"
              Value="1" />
                                        <Setter Property="BorderBrush">
                                            <Setter.Value>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"
                 Offset="0" />
                                                    <GradientStop Color="#FF8399A9"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF718597"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF617584"
                 Offset="1" />
                                                </LinearGradientBrush>
                                            </Setter.Value>
                                        </Setter>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid x:Name="grid"
                 Height="14"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Width="15"
                 Background="#02FFFFFF">
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="CommonStates">
                                                                <VisualState x:Name="Normal" />
                                                                <VisualState x:Name="MouseOver">
                                                                    <Storyboard>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.95" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Pressed">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.85" />
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Disabled">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.5" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <Path x:Name="X_Fuzz2"
                  Fill="#14C51900"
                  Stretch="Fill"
                  Stroke="#14C51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.3"
                     ScaleY="1.3" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz1"
                  Fill="#1EC51900"
                  Stretch="Fill"
                  Stroke="#1EC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.1"
                     ScaleY="1.1" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz0"
                  Fill="#FFC51900"
                  Stretch="Fill"
                  Stroke="#FFC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z" />
                                                        <Path x:Name="X"
                  Fill="#FFFFFFFF"
                  Stretch="Fill"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="0.7"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.Stroke>
                                                                <LinearGradientBrush EndPoint="0.5,1"
                    StartPoint="0.5,0">
                                                                    <GradientStop Color="#FF313131"
                     Offset="1" />
                                                                    <GradientStop Color="#FF8E9092"
                     Offset="0" />
                                                                </LinearGradientBrush>
                                                            </Path.Stroke>
                                                        </Path>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Grid.Resources>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="WindowStates">
                                        <VisualState x:Name="Open">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Closed">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="1" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Grid x:Name="Overlay"
            HorizontalAlignment="Stretch"
            Margin="0"
            VerticalAlignment="Top"
            Opacity="{TemplateBinding OverlayOpacity}"
            Background="{TemplateBinding OverlayBrush}" />
                                <Grid x:Name="ContentRoot"
            Height="{TemplateBinding Height}"
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
            VerticalAlignment="{TemplateBinding VerticalAlignment}"
            Width="{TemplateBinding Width}"
            RenderTransformOrigin="0.5,0.5">
                                    <Grid.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </Grid.RenderTransform>
                                    <Border HorizontalAlignment="Stretch"
             Margin="-1"
             VerticalAlignment="Stretch"
             Background="#0F000000"
             BorderBrush="#14000000"
             BorderThickness="1"
             CornerRadius="2" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-2"
             VerticalAlignment="Stretch"
             Background="#0E000000"
             BorderBrush="#0F000000"
             BorderThickness="1"
             CornerRadius="2.25" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-3"
             VerticalAlignment="Stretch"
             Background="#0C000000"
             BorderBrush="#0C000000"
             BorderThickness="1"
             CornerRadius="2.5" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-4"
             VerticalAlignment="Stretch"
             Background="#0A000000"
             BorderBrush="#0A000000"
             BorderThickness="1"
             CornerRadius="2.75" />
                                    <Border Background="#FF6D7C96"
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
             CornerRadius="3">
                                        <Border Margin="1"
              CornerRadius="3">
                                            <Border.Background>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FF00102E"
                 Offset="0.766" />
                                                    <GradientStop Color="#CBEBE8E5"
                 Offset="0" />
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                <Border x:Name="Chrome"
                Height="36"
                Width="Auto"
                BorderBrush="#FF00102E"
                BorderThickness="0,0,0,1"
                CornerRadius="3">
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,0.528"
                  StartPoint="0.5,0">
                                                            <GradientStop Color="#CBE5E8EB"
                   Offset="1" />
                                                            <GradientStop Color="#FF000F2D"
                   Offset="0" />
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                    <Border Height="Auto"
                 Width="Auto"
                 Background="{StaticResource BrushGridUnderChrome}"
                 CornerRadius="3">
                                                        <Grid>
                                                            <ContentControl FontWeight="Bold"
                   Foreground="#FFEFF2F4"
                   IsTabStop="False"
                   HorizontalAlignment="Stretch"
                   Margin="12,0,11,0"
                   VerticalAlignment="Center"
                   Content="{TemplateBinding Title}" />
                                                            <Button x:Name="CloseButton"
                   IsTabStop="False"
                   Height="14"
                   HorizontalAlignment="Right"
                   Margin="0,0,16,0"
                   Style="{StaticResource ButtonStyle}"
                   VerticalAlignment="Center"
                   Width="15"
                   RenderTransformOrigin="0.5,0.5"
                   Grid.Column="1">
                                                                <Button.RenderTransform>
                                                                    <TransformGroup>
                                                                        <ScaleTransform ScaleX="1.5"
                      ScaleY="1.5" />
                                                                        <SkewTransform />
                                                                        <RotateTransform />
                                                                        <TranslateTransform />
                                                                    </TransformGroup>
                                                                </Button.RenderTransform>
                                                            </Button>
                                                        </Grid>
                                                    </Border>
                                                </Border>
                                                <Border Margin="7"
                Grid.Row="1"
                Background="{TemplateBinding Background}">
                                                    <ContentPresenter x:Name="ContentPresenter"
                 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                 VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                 OpacityMask="#FF6C7B95"
                 Content="{TemplateBinding Content}"
                 ContentTemplate="{TemplateBinding ContentTemplate}" />
                                                </Border>
                                            </Grid>
                                        </Border>
                                    </Border>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>


                 </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>

    Thursday, May 19, 2011 7:13 AM
  • What xeonix_ is suggesting you is that you put a <ResourceDictionary> tag around all the styles you're defining after the imports you're doing of other styles.

    <LinearGradientBrush...

    all that to a new <ResourceDictionary> inside the MergedDictionaries tag

    Thursday, May 19, 2011 7:13 AM
  • Ok, let's try the following:
    put back your markup from "<controls:ChildWindow.Resources>" to "<Application.Resources>".
    remove "Style="{StaticResource ChildWindowStyleLawBot}" from the child window, but keep in "CildWindow"

    <Grid x:Name="LayoutRoot" Margin="2" Background="{StaticResource ChildWindowLayoutRootBackgroundBrush}">

    And see whatever it throw exception, or it could find the "ChildWindowLayoutRootBackgroundBrush".
    Additionaly, in ChildWindow's constructor before "InitializeComponent();"
    write:

    object childWindowStyleLawBot = Application.Current.Resources["ChildWindowStyleLawBot"];

    place break point and check, if "childWindowStyleLawBot" is null.
    This should clarify the problem.

    Thursday, May 19, 2011 8:05 AM
  • Ok, I know what is wrong.

    I am using PRISM therefore I have 2 app.xaml files. One for the shell and the other for the module.

    The resources must be added to the one in the shell not the one in the module as I was doing.

    Thanks for all your help.

    Thursday, May 19, 2011 8:41 AM
  • Actually when you're creating module which should be downloaded as separate XAP, "App.xaml" is not needed, so you can delete it.

    Thursday, May 19, 2011 8:49 AM

All replies

  • try:

     

    <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Brushes.xaml"/>
                    <ResourceDictionary Source="Assets/Fonts.xaml"/>
                    <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Assets/SdkStyles.xaml"/>

    <ResourceDictionary>
           
    <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black"  Offset="0" />
                <GradientStop Color="#FF6D7C96" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="BrushGridUnderChrome"  EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#D2000F2D" Offset="1" />
                <GradientStop Color="#43FFFFFF" />
                <GradientStop Color="#E87F8796" Offset="0.5" />
     </LinearGradientBrush>
     <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF6C7B95" Offset="0" />
                    <GradientStop Color="#FF000F2D" Offset="1" />
                    <GradientStop Color="#FF000F2D" Offset="0.15" />
                    <GradientStop Color="#FF000F2D"  Offset="0.15" />
      </LinearGradientBrush>

    <Style x:Key="ChildWindowStyleLawBot" TargetType="sdk:ChildWindow">
                <Setter Property="IsTabStop"  Value="false" />
                <Setter Property="TabNavigation"
     .................
    ....................
    </ResourceDictionary>


        </ResourceDictionary.MergedDictionaries>

    Thursday, May 19, 2011 6:45 AM
  • Hi xeonix_,

    Thanks a lot for your reply.

    I did not quite understand what I have to do. I am posting below my full App.xaml with the resources. Could you please clarify what I have to change?

    Cheers

    <Application x:Class="CodeGeneratorModule.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:System="clr-namespace:System;assembly=mscorlib"
                
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                         >

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Brushes.xaml"/>
                    <ResourceDictionary Source="Assets/Fonts.xaml"/>
                    <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Assets/SdkStyles.xaml"/>

                 </ResourceDictionary.MergedDictionaries>

     
            <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="Black"
        Offset="0" />
                <GradientStop Color="#FF6D7C96"
        Offset="1" />
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="BrushGridUnderChrome"
       EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="#D2000F2D"
        Offset="1" />
                <GradientStop Color="#43FFFFFF" />
                <GradientStop Color="#E87F8796"
        Offset="0.5" />
            </LinearGradientBrush>

                <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                    <GradientStop Color="#FF6C7B95"
        Offset="0" />
                    <GradientStop Color="#FF000F2D"
        Offset="1" />
                    <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                    <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                </LinearGradientBrush>


                <Style x:Key="ChildWindowStyleLawBot" TargetType="sdk:ChildWindow">
                <Setter Property="IsTabStop"
        Value="false" />
                <Setter Property="TabNavigation"
        Value="Cycle" />
                <Setter Property="HorizontalAlignment"
        Value="Center" />
                <Setter Property="VerticalAlignment"
        Value="Center" />
                <Setter Property="HorizontalContentAlignment"
        Value="Stretch" />
                <Setter Property="VerticalContentAlignment"
        Value="Stretch" />
                <Setter Property="BorderThickness"
        Value="1" />
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1"
          StartPoint="0.5,0">
                            <GradientStop Color="#FFA3AEB9"
           Offset="0" />
                            <GradientStop Color="#FF8399A9"
           Offset="0.375" />
                            <GradientStop Color="#FF718597"
           Offset="0.375" />
                            <GradientStop Color="#FF617584"
           Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="OverlayBrush"
        Value="#7F000000" />
                <Setter Property="OverlayOpacity"
        Value="1" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="sdk:ChildWindow">
                            <Grid x:Name="Root">
                                <Grid.Resources>
                                    <Style x:Key="ButtonStyle"
             TargetType="Button">
                                        <Setter Property="Background"
              Value="#FF1F3B53" />
                                        <Setter Property="Foreground"
              Value="#FF000000" />
                                        <Setter Property="Padding"
              Value="3" />
                                        <Setter Property="BorderThickness"
              Value="1" />
                                        <Setter Property="BorderBrush">
                                            <Setter.Value>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"
                 Offset="0" />
                                                    <GradientStop Color="#FF8399A9"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF718597"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF617584"
                 Offset="1" />
                                                </LinearGradientBrush>
                                            </Setter.Value>
                                        </Setter>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid x:Name="grid"
                 Height="14"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Width="15"
                 Background="#02FFFFFF">
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="CommonStates">
                                                                <VisualState x:Name="Normal" />
                                                                <VisualState x:Name="MouseOver">
                                                                    <Storyboard>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.95" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Pressed">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.85" />
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Disabled">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.5" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <Path x:Name="X_Fuzz2"
                  Fill="#14C51900"
                  Stretch="Fill"
                  Stroke="#14C51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.3"
                     ScaleY="1.3" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz1"
                  Fill="#1EC51900"
                  Stretch="Fill"
                  Stroke="#1EC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.1"
                     ScaleY="1.1" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz0"
                  Fill="#FFC51900"
                  Stretch="Fill"
                  Stroke="#FFC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z" />
                                                        <Path x:Name="X"
                  Fill="#FFFFFFFF"
                  Stretch="Fill"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="0.7"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.Stroke>
                                                                <LinearGradientBrush EndPoint="0.5,1"
                    StartPoint="0.5,0">
                                                                    <GradientStop Color="#FF313131"
                     Offset="1" />
                                                                    <GradientStop Color="#FF8E9092"
                     Offset="0" />
                                                                </LinearGradientBrush>
                                                            </Path.Stroke>
                                                        </Path>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Grid.Resources>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="WindowStates">
                                        <VisualState x:Name="Open">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Closed">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="1" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Grid x:Name="Overlay"
            HorizontalAlignment="Stretch"
            Margin="0"
            VerticalAlignment="Top"
            Opacity="{TemplateBinding OverlayOpacity}"
            Background="{TemplateBinding OverlayBrush}" />
                                <Grid x:Name="ContentRoot"
            Height="{TemplateBinding Height}"
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
            VerticalAlignment="{TemplateBinding VerticalAlignment}"
            Width="{TemplateBinding Width}"
            RenderTransformOrigin="0.5,0.5">
                                    <Grid.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </Grid.RenderTransform>
                                    <Border HorizontalAlignment="Stretch"
             Margin="-1"
             VerticalAlignment="Stretch"
             Background="#0F000000"
             BorderBrush="#14000000"
             BorderThickness="1"
             CornerRadius="2" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-2"
             VerticalAlignment="Stretch"
             Background="#0E000000"
             BorderBrush="#0F000000"
             BorderThickness="1"
             CornerRadius="2.25" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-3"
             VerticalAlignment="Stretch"
             Background="#0C000000"
             BorderBrush="#0C000000"
             BorderThickness="1"
             CornerRadius="2.5" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-4"
             VerticalAlignment="Stretch"
             Background="#0A000000"
             BorderBrush="#0A000000"
             BorderThickness="1"
             CornerRadius="2.75" />
                                    <Border Background="#FF6D7C96"
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
             CornerRadius="3">
                                        <Border Margin="1"
              CornerRadius="3">
                                            <Border.Background>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FF00102E"
                 Offset="0.766" />
                                                    <GradientStop Color="#CBEBE8E5"
                 Offset="0" />
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                <Border x:Name="Chrome"
                Height="36"
                Width="Auto"
                BorderBrush="#FF00102E"
                BorderThickness="0,0,0,1"
                CornerRadius="3">
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,0.528"
                  StartPoint="0.5,0">
                                                            <GradientStop Color="#CBE5E8EB"
                   Offset="1" />
                                                            <GradientStop Color="#FF000F2D"
                   Offset="0" />
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                    <Border Height="Auto"
                 Width="Auto"
                 Background="{StaticResource BrushGridUnderChrome}"
                 CornerRadius="3">
                                                        <Grid>
                                                            <ContentControl FontWeight="Bold"
                   Foreground="#FFEFF2F4"
                   IsTabStop="False"
                   HorizontalAlignment="Stretch"
                   Margin="12,0,11,0"
                   VerticalAlignment="Center"
                   Content="{TemplateBinding Title}" />
                                                            <Button x:Name="CloseButton"
                   IsTabStop="False"
                   Height="14"
                   HorizontalAlignment="Right"
                   Margin="0,0,16,0"
                   Style="{StaticResource ButtonStyle}"
                   VerticalAlignment="Center"
                   Width="15"
                   RenderTransformOrigin="0.5,0.5"
                   Grid.Column="1">
                                                                <Button.RenderTransform>
                                                                    <TransformGroup>
                                                                        <ScaleTransform ScaleX="1.5"
                      ScaleY="1.5" />
                                                                        <SkewTransform />
                                                                        <RotateTransform />
                                                                        <TranslateTransform />
                                                                    </TransformGroup>
                                                                </Button.RenderTransform>
                                                            </Button>
                                                        </Grid>
                                                    </Border>
                                                </Border>
                                                <Border Margin="7"
                Grid.Row="1"
                Background="{TemplateBinding Background}">
                                                    <ContentPresenter x:Name="ContentPresenter"
                 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                 VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                 OpacityMask="#FF6C7B95"
                 Content="{TemplateBinding Content}"
                 ContentTemplate="{TemplateBinding ContentTemplate}" />
                                                </Border>
                                            </Grid>
                                        </Border>
                                    </Border>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            </ResourceDictionary>

        </Application.Resources>

    </Application>

    Thursday, May 19, 2011 7:01 AM
  • At the root of "[Something].Resources" (in your case "Application.Resources") there's only
    one "<ResourceDictionary>" is allowed, and if you specified it, "<Application.Resources>"
    should contain nothing else, but just one "<ResourceDictionary>".
    In the markup you posted, you're putting other resources (LinearGradientBrush, Style, etc.) at the root
    of Application.Resources.
    And ther is one more thing:
    If you're using "<ResourceDictionary.MergedDictionaries>" of "<ResourceDictionary>", it could not contain
    any other resources.

    Let's get back to your markup.
    You have to put all your resources, delcared in "App.xaml" into "<ResourceDictionary>", and put it
    into "<ResourceDictionary.MergedDictionaries>".
    Your markup should look like this:


    <Application x:Class="CodeGeneratorModule.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:System="clr-namespace:System;assembly=mscorlib"
                
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                         >
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Brushes.xaml"/>
                    <ResourceDictionary Source="Assets/Fonts.xaml"/>
                    <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Assets/SdkStyles.xaml"/>


    <ResourceDictionary>
            <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="Black"
        Offset="0" />
                <GradientStop Color="#FF6D7C96"
        Offset="1" />
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="BrushGridUnderChrome"
       EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="#D2000F2D"
        Offset="1" />
                <GradientStop Color="#43FFFFFF" />
                <GradientStop Color="#E87F8796"
        Offset="0.5" />
            </LinearGradientBrush>
                <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                    <GradientStop Color="#FF6C7B95"
        Offset="0" />
                    <GradientStop Color="#FF000F2D"
        Offset="1" />
                    <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                    <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                </LinearGradientBrush>

                <Style x:Key="ChildWindowStyleLawBot" TargetType="sdk:ChildWindow">
                <Setter Property="IsTabStop"
        Value="false" />
                <Setter Property="TabNavigation"
        Value="Cycle" />
                <Setter Property="HorizontalAlignment"
        Value="Center" />
                <Setter Property="VerticalAlignment"
        Value="Center" />
                <Setter Property="HorizontalContentAlignment"
        Value="Stretch" />
                <Setter Property="VerticalContentAlignment"
        Value="Stretch" />
                <Setter Property="BorderThickness"
        Value="1" />
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1"
          StartPoint="0.5,0">
                            <GradientStop Color="#FFA3AEB9"
           Offset="0" />
                            <GradientStop Color="#FF8399A9"
           Offset="0.375" />
                            <GradientStop Color="#FF718597"
           Offset="0.375" />
                            <GradientStop Color="#FF617584"
           Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="OverlayBrush"
        Value="#7F000000" />
                <Setter Property="OverlayOpacity"
        Value="1" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="sdk:ChildWindow">
                            <Grid x:Name="Root">
                                <Grid.Resources>
                                    <Style x:Key="ButtonStyle"
             TargetType="Button">
                                        <Setter Property="Background"
              Value="#FF1F3B53" />
                                        <Setter Property="Foreground"
              Value="#FF000000" />
                                        <Setter Property="Padding"
              Value="3" />
                                        <Setter Property="BorderThickness"
              Value="1" />
                                        <Setter Property="BorderBrush">
                                            <Setter.Value>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"
                 Offset="0" />
                                                    <GradientStop Color="#FF8399A9"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF718597"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF617584"
                 Offset="1" />
                                                </LinearGradientBrush>
                                            </Setter.Value>
                                        </Setter>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid x:Name="grid"
                 Height="14"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Width="15"
                 Background="#02FFFFFF">
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="CommonStates">
                                                                <VisualState x:Name="Normal" />
                                                                <VisualState x:Name="MouseOver">
                                                                    <Storyboard>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.95" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Pressed">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.85" />
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Disabled">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.5" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <Path x:Name="X_Fuzz2"
                  Fill="#14C51900"
                  Stretch="Fill"
                  Stroke="#14C51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.3"
                     ScaleY="1.3" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz1"
                  Fill="#1EC51900"
                  Stretch="Fill"
                  Stroke="#1EC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.1"
                     ScaleY="1.1" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz0"
                  Fill="#FFC51900"
                  Stretch="Fill"
                  Stroke="#FFC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z" />
                                                        <Path x:Name="X"
                  Fill="#FFFFFFFF"
                  Stretch="Fill"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="0.7"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.Stroke>
                                                                <LinearGradientBrush EndPoint="0.5,1"
                    StartPoint="0.5,0">
                                                                    <GradientStop Color="#FF313131"
                     Offset="1" />
                                                                    <GradientStop Color="#FF8E9092"
                     Offset="0" />
                                                                </LinearGradientBrush>
                                                            </Path.Stroke>
                                                        </Path>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Grid.Resources>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="WindowStates">
                                        <VisualState x:Name="Open">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Closed">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="1" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Grid x:Name="Overlay"
            HorizontalAlignment="Stretch"
            Margin="0"
            VerticalAlignment="Top"
            Opacity="{TemplateBinding OverlayOpacity}"
            Background="{TemplateBinding OverlayBrush}" />
                                <Grid x:Name="ContentRoot"
            Height="{TemplateBinding Height}"
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
            VerticalAlignment="{TemplateBinding VerticalAlignment}"
            Width="{TemplateBinding Width}"
            RenderTransformOrigin="0.5,0.5">
                                    <Grid.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </Grid.RenderTransform>
                                    <Border HorizontalAlignment="Stretch"
             Margin="-1"
             VerticalAlignment="Stretch"
             Background="#0F000000"
             BorderBrush="#14000000"
             BorderThickness="1"
             CornerRadius="2" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-2"
             VerticalAlignment="Stretch"
             Background="#0E000000"
             BorderBrush="#0F000000"
             BorderThickness="1"
             CornerRadius="2.25" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-3"
             VerticalAlignment="Stretch"
             Background="#0C000000"
             BorderBrush="#0C000000"
             BorderThickness="1"
             CornerRadius="2.5" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-4"
             VerticalAlignment="Stretch"
             Background="#0A000000"
             BorderBrush="#0A000000"
             BorderThickness="1"
             CornerRadius="2.75" />
                                    <Border Background="#FF6D7C96"
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
             CornerRadius="3">
                                        <Border Margin="1"
              CornerRadius="3">
                                            <Border.Background>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FF00102E"
                 Offset="0.766" />
                                                    <GradientStop Color="#CBEBE8E5"
                 Offset="0" />
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                <Border x:Name="Chrome"
                Height="36"
                Width="Auto"
                BorderBrush="#FF00102E"
                BorderThickness="0,0,0,1"
                CornerRadius="3">
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,0.528"
                  StartPoint="0.5,0">
                                                            <GradientStop Color="#CBE5E8EB"
                   Offset="1" />
                                                            <GradientStop Color="#FF000F2D"
                   Offset="0" />
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                    <Border Height="Auto"
                 Width="Auto"
                 Background="{StaticResource BrushGridUnderChrome}"
                 CornerRadius="3">
                                                        <Grid>
                                                            <ContentControl FontWeight="Bold"
                   Foreground="#FFEFF2F4"
                   IsTabStop="False"
                   HorizontalAlignment="Stretch"
                   Margin="12,0,11,0"
                   VerticalAlignment="Center"
                   Content="{TemplateBinding Title}" />
                                                            <Button x:Name="CloseButton"
                   IsTabStop="False"
                   Height="14"
                   HorizontalAlignment="Right"
                   Margin="0,0,16,0"
                   Style="{StaticResource ButtonStyle}"
                   VerticalAlignment="Center"
                   Width="15"
                   RenderTransformOrigin="0.5,0.5"
                   Grid.Column="1">
                                                                <Button.RenderTransform>
                                                                    <TransformGroup>
                                                                        <ScaleTransform ScaleX="1.5"
                      ScaleY="1.5" />
                                                                        <SkewTransform />
                                                                        <RotateTransform />
                                                                        <TranslateTransform />
                                                                    </TransformGroup>
                                                                </Button.RenderTransform>
                                                            </Button>
                                                        </Grid>
                                                    </Border>
                                                </Border>
                                                <Border Margin="7"
                Grid.Row="1"
                Background="{TemplateBinding Background}">
                                                    <ContentPresenter x:Name="ContentPresenter"
                 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                 VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                 OpacityMask="#FF6C7B95"
                 Content="{TemplateBinding Content}"
                 ContentTemplate="{TemplateBinding ContentTemplate}" />
                                                </Border>
                                            </Grid>
                                        </Border>
                                    </Border>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>


                 </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>

    Thursday, May 19, 2011 7:13 AM
  • What xeonix_ is suggesting you is that you put a <ResourceDictionary> tag around all the styles you're defining after the imports you're doing of other styles.

    <LinearGradientBrush...

    all that to a new <ResourceDictionary> inside the MergedDictionaries tag

    Thursday, May 19, 2011 7:13 AM
  • Hi thanks for your help.

    I made the changes you suggested but am still getting the same error when I hit the InitializeComponent() method.

    1 - Do I need to reference the resouce in code behind?

    2 - Is there a way I can move the resources to the ChildWindow itself since I cannot figure out what is wrong?

    This is my full ChildWindow Code behind:
    --------------------------------------------------
    public partial class ReadCodeChildWindow : ChildWindow
        {
            private Code _code;

            public ReadCodeChildWindow(Code code)
            {
                InitializeComponent(); // BREAKS HERE
                _code = code;

                CreateCode();
            }

            private void CreateCode()
            {
                StringBuilder textCodeBuilder = new StringBuilder();
                textCodeBuilder.Append(_code.ApplicationName);
                textCodeBuilder.Append(Environment.NewLine);
                textCodeBuilder.Append(_code.DaysLeftCheck);
                textCodeBuilder.Append(Environment.NewLine);
                textCodeBuilder.Append(_code.EarlyWarning);
                textCodeBuilder.Append(Environment.NewLine);
                textCodeBuilder.Append(_code.ExpiryDate);
                textCodeBuilder.Append(Environment.NewLine);
                textCodeBuilder.Append(_code.HardwareId);
                textCodeBuilder.Append(Environment.NewLine);
                textCodeBuilder.Append(_code.Message);
                textCodeBuilder.Append(Environment.NewLine);

                if (_code.Options != null)
                {
                    if (_code.ApplicationName.ToLower().IndexOf("choices") != -1)
                    {
                        textCodeBuilder.Append("\tOptions");
                        textCodeBuilder.Append(Environment.NewLine);
                    }
                    else if (_code.ApplicationName.ToLower().IndexOf("ptk") != -1)
                    {
                        textCodeBuilder.Append("\tPermissions");
                        textCodeBuilder.Append(Environment.NewLine);
                    }
                    else
                    {

                    }

                    foreach (var item in _code.Options)
                    {
                        textCodeBuilder.Append("\t" + item);
                        textCodeBuilder.Append(Environment.NewLine);
                    }
                }
                txtCode.Text = textCodeBuilder.ToString();
            }

            private void OKButton_Click(object sender, RoutedEventArgs e)
            {
                this.DialogResult = true;
            }

            private void CancelButton_Click(object sender, RoutedEventArgs e)
            {
                this.DialogResult = false;
            }
        }

    Full ChildWindow xaml
    ----------------------------

    <controls:ChildWindow x:Class="CodeGeneratorModule.Views.ReadCodeChildWindow"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
               Width="600" Height="500"
               Title="Generated Code" Style="{StaticResource ChildWindowStyleLawBot}" FontFamily="Verdana">

        <Grid x:Name="LayoutRoot" Margin="2" Background="{StaticResource ChildWindowLayoutRootBackgroundBrush}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Button x:Name="CancelButton" Content="Close" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
            <!--<Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />-->
           
            <Border BorderBrush="{StaticResource LawBotInnerBorderBrush}" Margin="0,0,0,12" BorderThickness="1">
                <Grid Margin="1,0,1,2">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid x:Name="gdTopTitle" Margin="0,0,4,0">
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="0.5,1"
           StartPoint="0.5,0">
                                <GradientStop Color="#FF6C7B95"
            Offset="0" />
                                <GradientStop Color="#FF000F2D"
            Offset="1" />
                            </LinearGradientBrush>
                        </Grid.Background>
                        <StackPanel
          VerticalAlignment="Stretch"
          HorizontalAlignment="Stretch"
          Margin="13,0,0,0">
                         

                            <TextBlock x:Name="txtCode"
           HorizontalAlignment="Stretch"
           VerticalAlignment="Stretch"
           FontSize="12"
           Foreground="White"
           TextWrapping="Wrap"
           FontWeight="Bold" />
                           
                        </StackPanel>
                    </Grid>
                </Grid>
            </Border>
        </Grid>
    </controls:ChildWindow>

    Full App.xaml:

    <Application x:Class="CodeGeneratorModule.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:System="clr-namespace:System;assembly=mscorlib"
                
                 xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                         >

        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Assets/Brushes.xaml"/>
                    <ResourceDictionary Source="Assets/Fonts.xaml"/>
                    <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
                    <ResourceDictionary Source="Assets/Styles.xaml"/>
                    <ResourceDictionary Source="Assets/SdkStyles.xaml"/>

                    <ResourceDictionary>

                        <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                            <GradientStop Color="Black"
        Offset="0" />
                            <GradientStop Color="#FF6D7C96"
        Offset="1" />
                        </LinearGradientBrush>

                        <LinearGradientBrush x:Key="BrushGridUnderChrome"
       EndPoint="0.5,1"
       StartPoint="0.5,0">
                            <GradientStop Color="#D2000F2D"
        Offset="1" />
                            <GradientStop Color="#43FFFFFF" />
                            <GradientStop Color="#E87F8796"
        Offset="0.5" />
                        </LinearGradientBrush>

                        <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                            <GradientStop Color="#FF6C7B95"
        Offset="0" />
                            <GradientStop Color="#FF000F2D"
        Offset="1" />
                            <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                            <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                        </LinearGradientBrush>


                        <Style x:Key="ChildWindowStyleLawBot" TargetType="sdk:ChildWindow">
                            <Setter Property="IsTabStop"
        Value="false" />
                            <Setter Property="TabNavigation"
        Value="Cycle" />
                            <Setter Property="HorizontalAlignment"
        Value="Center" />
                            <Setter Property="VerticalAlignment"
        Value="Center" />
                            <Setter Property="HorizontalContentAlignment"
        Value="Stretch" />
                            <Setter Property="VerticalContentAlignment"
        Value="Stretch" />
                            <Setter Property="BorderThickness"
        Value="1" />
                            <Setter Property="BorderBrush">
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0.5,1"
          StartPoint="0.5,0">
                                        <GradientStop Color="#FFA3AEB9"
           Offset="0" />
                                        <GradientStop Color="#FF8399A9"
           Offset="0.375" />
                                        <GradientStop Color="#FF718597"
           Offset="0.375" />
                                        <GradientStop Color="#FF617584"
           Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="OverlayBrush"
        Value="#7F000000" />
                            <Setter Property="OverlayOpacity"
        Value="1" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="sdk:ChildWindow">
                                        <Grid x:Name="Root">
                                            <Grid.Resources>
                                                <Style x:Key="ButtonStyle"
             TargetType="Button">
                                                    <Setter Property="Background"
              Value="#FF1F3B53" />
                                                    <Setter Property="Foreground"
              Value="#FF000000" />
                                                    <Setter Property="Padding"
              Value="3" />
                                                    <Setter Property="BorderThickness"
              Value="1" />
                                                    <Setter Property="BorderBrush">
                                                        <Setter.Value>
                                                            <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                                <GradientStop Color="#FFA3AEB9"
                 Offset="0" />
                                                                <GradientStop Color="#FF8399A9"
                 Offset="0.375" />
                                                                <GradientStop Color="#FF718597"
                 Offset="0.375" />
                                                                <GradientStop Color="#FF617584"
                 Offset="1" />
                                                            </LinearGradientBrush>
                                                        </Setter.Value>
                                                    </Setter>
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="Button">
                                                                <Grid x:Name="grid"
                 Height="14"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Width="15"
                 Background="#02FFFFFF">
                                                                    <VisualStateManager.VisualStateGroups>
                                                                        <VisualStateGroup x:Name="CommonStates">
                                                                            <VisualState x:Name="Normal" />
                                                                            <VisualState x:Name="MouseOver">
                                                                                <Storyboard>
                                                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                                        <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                                    </ObjectAnimationUsingKeyFrames>
                                                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                                        <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                                    </ObjectAnimationUsingKeyFrames>
                                                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                                        <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                                    </ObjectAnimationUsingKeyFrames>
                                                                                    <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.95" />
                                                                                </Storyboard>
                                                                            </VisualState>
                                                                            <VisualState x:Name="Pressed">
                                                                                <Storyboard>
                                                                                    <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.85" />
                                                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                                        <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                                    </ObjectAnimationUsingKeyFrames>
                                                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                                        <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                                    </ObjectAnimationUsingKeyFrames>
                                                                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                                        <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                                    </ObjectAnimationUsingKeyFrames>
                                                                                </Storyboard>
                                                                            </VisualState>
                                                                            <VisualState x:Name="Disabled">
                                                                                <Storyboard>
                                                                                    <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.5" />
                                                                                </Storyboard>
                                                                            </VisualState>
                                                                        </VisualStateGroup>
                                                                    </VisualStateManager.VisualStateGroups>
                                                                    <Path x:Name="X_Fuzz2"
                  Fill="#14C51900"
                  Stretch="Fill"
                  Stroke="#14C51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                                        <Path.RenderTransform>
                                                                            <TransformGroup>
                                                                                <ScaleTransform ScaleX="1.3"
                     ScaleY="1.3" />
                                                                            </TransformGroup>
                                                                        </Path.RenderTransform>
                                                                    </Path>
                                                                    <Path x:Name="X_Fuzz1"
                  Fill="#1EC51900"
                  Stretch="Fill"
                  Stroke="#1EC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                                        <Path.RenderTransform>
                                                                            <TransformGroup>
                                                                                <ScaleTransform ScaleX="1.1"
                     ScaleY="1.1" />
                                                                            </TransformGroup>
                                                                        </Path.RenderTransform>
                                                                    </Path>
                                                                    <Path x:Name="X_Fuzz0"
                  Fill="#FFC51900"
                  Stretch="Fill"
                  Stroke="#FFC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z" />
                                                                    <Path x:Name="X"
                  Fill="#FFFFFFFF"
                  Stretch="Fill"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="0.7"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                                        <Path.Stroke>
                                                                            <LinearGradientBrush EndPoint="0.5,1"
                    StartPoint="0.5,0">
                                                                                <GradientStop Color="#FF313131"
                     Offset="1" />
                                                                                <GradientStop Color="#FF8E9092"
                     Offset="0" />
                                                                            </LinearGradientBrush>
                                                                        </Path.Stroke>
                                                                    </Path>
                                                                </Grid>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </Grid.Resources>
                                            <VisualStateManager.VisualStateGroups>
                                                <VisualStateGroup x:Name="WindowStates">
                                                    <VisualState x:Name="Open">
                                                        <Storyboard>
                                                            <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                                <EasingDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                                <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="1" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                            <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                                <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                            <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                                <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </VisualState>
                                                    <VisualState x:Name="Closed">
                                                        <Storyboard>
                                                            <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                                <EasingDoubleKeyFrame KeyTime="0"
                 Value="1" />
                                                                <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="0" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                            <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                            <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                                <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </VisualState>
                                                </VisualStateGroup>
                                            </VisualStateManager.VisualStateGroups>
                                            <Grid x:Name="Overlay"
            HorizontalAlignment="Stretch"
            Margin="0"
            VerticalAlignment="Top"
            Opacity="{TemplateBinding OverlayOpacity}"
            Background="{TemplateBinding OverlayBrush}" />
                                            <Grid x:Name="ContentRoot"
            Height="{TemplateBinding Height}"
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
            VerticalAlignment="{TemplateBinding VerticalAlignment}"
            Width="{TemplateBinding Width}"
            RenderTransformOrigin="0.5,0.5">
                                                <Grid.RenderTransform>
                                                    <TransformGroup>
                                                        <ScaleTransform />
                                                        <SkewTransform />
                                                        <RotateTransform />
                                                        <TranslateTransform />
                                                    </TransformGroup>
                                                </Grid.RenderTransform>
                                                <Border HorizontalAlignment="Stretch"
             Margin="-1"
             VerticalAlignment="Stretch"
             Background="#0F000000"
             BorderBrush="#14000000"
             BorderThickness="1"
             CornerRadius="2" />
                                                <Border HorizontalAlignment="Stretch"
             Margin="-2"
             VerticalAlignment="Stretch"
             Background="#0E000000"
             BorderBrush="#0F000000"
             BorderThickness="1"
             CornerRadius="2.25" />
                                                <Border HorizontalAlignment="Stretch"
             Margin="-3"
             VerticalAlignment="Stretch"
             Background="#0C000000"
             BorderBrush="#0C000000"
             BorderThickness="1"
             CornerRadius="2.5" />
                                                <Border HorizontalAlignment="Stretch"
             Margin="-4"
             VerticalAlignment="Stretch"
             Background="#0A000000"
             BorderBrush="#0A000000"
             BorderThickness="1"
             CornerRadius="2.75" />
                                                <Border Background="#FF6D7C96"
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
             CornerRadius="3">
                                                    <Border Margin="1"
              CornerRadius="3">
                                                        <Border.Background>
                                                            <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                                <GradientStop Color="#FF00102E"
                 Offset="0.766" />
                                                                <GradientStop Color="#CBEBE8E5"
                 Offset="0" />
                                                            </LinearGradientBrush>
                                                        </Border.Background>
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="Auto" />
                                                                <RowDefinition />
                                                            </Grid.RowDefinitions>
                                                            <Border x:Name="Chrome"
                Height="36"
                Width="Auto"
                BorderBrush="#FF00102E"
                BorderThickness="0,0,0,1"
                CornerRadius="3">
                                                                <Border.Background>
                                                                    <LinearGradientBrush EndPoint="0.5,0.528"
                  StartPoint="0.5,0">
                                                                        <GradientStop Color="#CBE5E8EB"
                   Offset="1" />
                                                                        <GradientStop Color="#FF000F2D"
                   Offset="0" />
                                                                    </LinearGradientBrush>
                                                                </Border.Background>
                                                                <Border Height="Auto"
                 Width="Auto"
                 Background="{StaticResource BrushGridUnderChrome}"
                 CornerRadius="3">
                                                                    <Grid>
                                                                        <ContentControl FontWeight="Bold"
                   Foreground="#FFEFF2F4"
                   IsTabStop="False"
                   HorizontalAlignment="Stretch"
                   Margin="12,0,11,0"
                   VerticalAlignment="Center"
                   Content="{TemplateBinding Title}" />
                                                                        <Button x:Name="CloseButton"
                   IsTabStop="False"
                   Height="14"
                   HorizontalAlignment="Right"
                   Margin="0,0,16,0"
                   Style="{StaticResource ButtonStyle}"
                   VerticalAlignment="Center"
                   Width="15"
                   RenderTransformOrigin="0.5,0.5"
                   Grid.Column="1">
                                                                            <Button.RenderTransform>
                                                                                <TransformGroup>
                                                                                    <ScaleTransform ScaleX="1.5"
                      ScaleY="1.5" />
                                                                                    <SkewTransform />
                                                                                    <RotateTransform />
                                                                                    <TranslateTransform />
                                                                                </TransformGroup>
                                                                            </Button.RenderTransform>
                                                                        </Button>
                                                                    </Grid>
                                                                </Border>
                                                            </Border>
                                                            <Border Margin="7"
                Grid.Row="1"
                Background="{TemplateBinding Background}">
                                                                <ContentPresenter x:Name="ContentPresenter"
                 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                 VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                 OpacityMask="#FF6C7B95"
                 Content="{TemplateBinding Content}"
                 ContentTemplate="{TemplateBinding ContentTemplate}" />
                                                            </Border>
                                                        </Grid>
                                                    </Border>
                                                </Border>
                                            </Grid>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ResourceDictionary>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>

        </Application.Resources>

    </Application>

    Thursday, May 19, 2011 7:30 AM
  • Hi,

    I have tried another approach and I think the problem is this line Style="{StaticResource ChildWindowStyleLawBot}" in the
    <controls:ChildWindow header

    I have moved the styles to the <controls:ChildWindow.Resources> but it still cannot see the ChildWindowStyleLawBot.

    It seems that it is trying to reference it before it is created.

    Do you have any more ideas on how to fix it?

    Full modified ChildWindow xamml
    ----------------------------------------------

    <controls:ChildWindow x:Class="CodeGeneratorModule.Views.ReadCodeChildWindow"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
               Width="600" Height="500"
               Title="Generated Code" Style="{StaticResource ChildWindowStyleLawBot}" FontFamily="Verdana">
     

    <controls:ChildWindow.Resources>

            <LinearGradientBrush x:Key="LawBotInnerBorderBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="Black"
        Offset="0" />
                <GradientStop Color="#FF6D7C96"
        Offset="1" />
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="BrushGridUnderChrome"
       EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="#D2000F2D"
        Offset="1" />
                <GradientStop Color="#43FFFFFF" />
                <GradientStop Color="#E87F8796"
        Offset="0.5" />
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="ChildWindowLayoutRootBackgroundBrush" EndPoint="0.5,1"
       StartPoint="0.5,0">
                <GradientStop Color="#FF6C7B95"
        Offset="0" />
                <GradientStop Color="#FF000F2D"
        Offset="1" />
                <GradientStop Color="#FF000F2D"
        Offset="0.15" />
                <GradientStop Color="#FF000F2D"
        Offset="0.15" />
            </LinearGradientBrush>


    <Style x:Key="ChildWindowStyleLawBot" TargetType="controls:ChildWindow">
                <Setter Property="IsTabStop"
        Value="false" />
                <Setter Property="TabNavigation"
        Value="Cycle" />
                <Setter Property="HorizontalAlignment"
        Value="Center" />
                <Setter Property="VerticalAlignment"
        Value="Center" />
                <Setter Property="HorizontalContentAlignment"
        Value="Stretch" />
                <Setter Property="VerticalContentAlignment"
        Value="Stretch" />
                <Setter Property="BorderThickness"
        Value="1" />
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1"
          StartPoint="0.5,0">
                            <GradientStop Color="#FFA3AEB9"
           Offset="0" />
                            <GradientStop Color="#FF8399A9"
           Offset="0.375" />
                            <GradientStop Color="#FF718597"
           Offset="0.375" />
                            <GradientStop Color="#FF617584"
           Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="OverlayBrush"
        Value="#7F000000" />
                <Setter Property="OverlayOpacity"
        Value="1" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="controls:ChildWindow">
                            <Grid x:Name="Root">
                                <Grid.Resources>
                                    <Style x:Key="ButtonStyle"
             TargetType="Button">
                                        <Setter Property="Background"
              Value="#FF1F3B53" />
                                        <Setter Property="Foreground"
              Value="#FF000000" />
                                        <Setter Property="Padding"
              Value="3" />
                                        <Setter Property="BorderThickness"
              Value="1" />
                                        <Setter Property="BorderBrush">
                                            <Setter.Value>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"
                 Offset="0" />
                                                    <GradientStop Color="#FF8399A9"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF718597"
                 Offset="0.375" />
                                                    <GradientStop Color="#FF617584"
                 Offset="1" />
                                                </LinearGradientBrush>
                                            </Setter.Value>
                                        </Setter>
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="Button">
                                                    <Grid x:Name="grid"
                 Height="14"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Width="15"
                 Background="#02FFFFFF">
                                                        <VisualStateManager.VisualStateGroups>
                                                            <VisualStateGroup x:Name="CommonStates">
                                                                <VisualState x:Name="Normal" />
                                                                <VisualState x:Name="MouseOver">
                                                                    <Storyboard>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.95" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Pressed">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.85" />
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz2"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz1"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="X_Fuzz0"
                      Storyboard.TargetProperty="Visibility">
                                                                            <DiscreteObjectKeyFrame KeyTime="0"
                       Value="Visible" />
                                                                        </ObjectAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </VisualState>
                                                                <VisualState x:Name="Disabled">
                                                                    <Storyboard>
                                                                        <DoubleAnimation Duration="0"
                      Storyboard.TargetName="X"
                      Storyboard.TargetProperty="Opacity"
                      To="0.5" />
                                                                    </Storyboard>
                                                                </VisualState>
                                                            </VisualStateGroup>
                                                        </VisualStateManager.VisualStateGroups>
                                                        <Path x:Name="X_Fuzz2"
                  Fill="#14C51900"
                  Stretch="Fill"
                  Stroke="#14C51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.3"
                     ScaleY="1.3" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz1"
                  Fill="#1EC51900"
                  Stretch="Fill"
                  Stroke="#1EC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  RenderTransformOrigin="0.5,0.5"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.RenderTransform>
                                                                <TransformGroup>
                                                                    <ScaleTransform ScaleX="1.1"
                     ScaleY="1.1" />
                                                                </TransformGroup>
                                                            </Path.RenderTransform>
                                                        </Path>
                                                        <Path x:Name="X_Fuzz0"
                  Fill="#FFC51900"
                  Stretch="Fill"
                  Stroke="#FFC51900"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="1"
                  Visibility="Collapsed"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z" />
                                                        <Path x:Name="X"
                  Fill="#FFFFFFFF"
                  Stretch="Fill"
                  Height="8"
                  HorizontalAlignment="Center"
                  Margin="0,-1,0,0"
                  VerticalAlignment="Center"
                  Width="9"
                  Opacity="0.7"
                  Data="F1 M 6.742676,3.852539 L 9.110840,1.559570 L 8.910645,0.500000 L 6.838379,0.500000 L 4.902832,2.435547 L 2.967285,0.500000 L 0.895020,0.500000 L 0.694824,1.559570 L 3.062988,3.852539 L 0.527832,6.351563 L 0.689941,7.600586 L 2.967285,7.600586 L 4.897949,5.575195 L 6.854004,7.600586 L 9.115723,7.600586 L 9.277832,6.351563 L 6.742676,3.852539 Z">
                                                            <Path.Stroke>
                                                                <LinearGradientBrush EndPoint="0.5,1"
                    StartPoint="0.5,0">
                                                                    <GradientStop Color="#FF313131"
                     Offset="1" />
                                                                    <GradientStop Color="#FF8E9092"
                     Offset="0" />
                                                                </LinearGradientBrush>
                                                            </Path.Stroke>
                                                        </Path>
                                                    </Grid>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </Grid.Resources>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="WindowStates">
                                        <VisualState x:Name="Open">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="0"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="0" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.4"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="1.05"
                 KeySpline="0,0,0.5,1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.55"
                 Value="1" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Closed">
                                            <Storyboard>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="Overlay"
                Storyboard.TargetProperty="Opacity">
                                                    <EasingDoubleKeyFrame KeyTime="0"
                 Value="1" />
                                                    <EasingDoubleKeyFrame KeyTime="00:00:00.3"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleX">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                                <DoubleAnimationUsingKeyFrames BeginTime="0"
                Storyboard.TargetName="ContentRoot"
                Storyboard.TargetProperty="(RenderTransform).(Children)[0].ScaleY">
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2"
                 Value="1" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.25"
                 Value="1.05" />
                                                    <SplineDoubleKeyFrame KeyTime="00:00:00.45"
                 Value="0" />
                                                </DoubleAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Grid x:Name="Overlay"
            HorizontalAlignment="Stretch"
            Margin="0"
            VerticalAlignment="Top"
            Opacity="{TemplateBinding OverlayOpacity}"
            Background="{TemplateBinding OverlayBrush}" />
                                <Grid x:Name="ContentRoot"
            Height="{TemplateBinding Height}"
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
            VerticalAlignment="{TemplateBinding VerticalAlignment}"
            Width="{TemplateBinding Width}"
            RenderTransformOrigin="0.5,0.5">
                                    <Grid.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </Grid.RenderTransform>
                                    <Border HorizontalAlignment="Stretch"
             Margin="-1"
             VerticalAlignment="Stretch"
             Background="#0F000000"
             BorderBrush="#14000000"
             BorderThickness="1"
             CornerRadius="2" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-2"
             VerticalAlignment="Stretch"
             Background="#0E000000"
             BorderBrush="#0F000000"
             BorderThickness="1"
             CornerRadius="2.25" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-3"
             VerticalAlignment="Stretch"
             Background="#0C000000"
             BorderBrush="#0C000000"
             BorderThickness="1"
             CornerRadius="2.5" />
                                    <Border HorizontalAlignment="Stretch"
             Margin="-4"
             VerticalAlignment="Stretch"
             Background="#0A000000"
             BorderBrush="#0A000000"
             BorderThickness="1"
             CornerRadius="2.75" />
                                    <Border Background="#FF6D7C96"
             BorderBrush="{TemplateBinding BorderBrush}"
             BorderThickness="{TemplateBinding BorderThickness}"
             CornerRadius="3">
                                        <Border Margin="1"
              CornerRadius="3">
                                            <Border.Background>
                                                <LinearGradientBrush EndPoint="0.5,1"
                StartPoint="0.5,0">
                                                    <GradientStop Color="#FF00102E"
                 Offset="0.766" />
                                                    <GradientStop Color="#CBEBE8E5"
                 Offset="0" />
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition />
                                                </Grid.RowDefinitions>
                                                <Border x:Name="Chrome"
                Height="36"
                Width="Auto"
                BorderBrush="#FF00102E"
                BorderThickness="0,0,0,1"
                CornerRadius="3">
                                                    <Border.Background>
                                                        <LinearGradientBrush EndPoint="0.5,0.528"
                  StartPoint="0.5,0">
                                                            <GradientStop Color="#CBE5E8EB"
                   Offset="1" />
                                                            <GradientStop Color="#FF000F2D"
                   Offset="0" />
                                                        </LinearGradientBrush>
                                                    </Border.Background>
                                                    <Border Height="Auto"
                 Width="Auto"
                 Background="{StaticResource BrushGridUnderChrome}"
                 CornerRadius="3">
                                                        <Grid>
                                                            <ContentControl FontWeight="Bold"
                   Foreground="#FFEFF2F4"
                   IsTabStop="False"
                   HorizontalAlignment="Stretch"
                   Margin="12,0,11,0"
                   VerticalAlignment="Center"
                   Content="{TemplateBinding Title}" />
                                                            <Button x:Name="CloseButton"
                   IsTabStop="False"
                   Height="14"
                   HorizontalAlignment="Right"
                   Margin="0,0,16,0"
                   Style="{StaticResource ButtonStyle}"
                   VerticalAlignment="Center"
                   Width="15"
                   RenderTransformOrigin="0.5,0.5"
                   Grid.Column="1">
                                                                <Button.RenderTransform>
                                                                    <TransformGroup>
                                                                        <ScaleTransform ScaleX="1.5"
                      ScaleY="1.5" />
                                                                        <SkewTransform />
                                                                        <RotateTransform />
                                                                        <TranslateTransform />
                                                                    </TransformGroup>
                                                                </Button.RenderTransform>
                                                            </Button>
                                                        </Grid>
                                                    </Border>
                                                </Border>
                                                <Border Margin="7"
                Grid.Row="1"
                Background="{TemplateBinding Background}">
                                                    <ContentPresenter x:Name="ContentPresenter"
                 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                 VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                 OpacityMask="#FF6C7B95"
                 Content="{TemplateBinding Content}"
                 ContentTemplate="{TemplateBinding ContentTemplate}" />
                                                </Border>
                                            </Grid>
                                        </Border>
                                    </Border>
                                </Grid>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </controls:ChildWindow.Resources>

        <Grid x:Name="LayoutRoot" Margin="2" Background="{StaticResource ChildWindowLayoutRootBackgroundBrush}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Button x:Name="CancelButton" Content="Close" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
            <!--<Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />-->
           
            <Border BorderBrush="{StaticResource LawBotInnerBorderBrush}" Margin="0,0,0,12" BorderThickness="1">
                <Grid Margin="1,0,1,2">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid x:Name="gdTopTitle" Margin="0,0,4,0">
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="0.5,1"
           StartPoint="0.5,0">
                                <GradientStop Color="#FF6C7B95"
            Offset="0" />
                                <GradientStop Color="#FF000F2D"
            Offset="1" />
                            </LinearGradientBrush>
                        </Grid.Background>
                        <StackPanel
          VerticalAlignment="Stretch"
          HorizontalAlignment="Stretch"
          Margin="13,0,0,0">
                         

                            <TextBlock x:Name="txtCode"
           HorizontalAlignment="Stretch"
           VerticalAlignment="Stretch"
           FontSize="12"
           Foreground="White"
           TextWrapping="Wrap"
           FontWeight="Bold" />
                           
                        </StackPanel>
                    </Grid>
                </Grid>
            </Border>
        </Grid>
    </controls:ChildWindow>

    Thursday, May 19, 2011 7:48 AM
  • Ok, let's try the following:
    put back your markup from "<controls:ChildWindow.Resources>" to "<Application.Resources>".
    remove "Style="{StaticResource ChildWindowStyleLawBot}" from the child window, but keep in "CildWindow"

    <Grid x:Name="LayoutRoot" Margin="2" Background="{StaticResource ChildWindowLayoutRootBackgroundBrush}">

    And see whatever it throw exception, or it could find the "ChildWindowLayoutRootBackgroundBrush".
    Additionaly, in ChildWindow's constructor before "InitializeComponent();"
    write:

    object childWindowStyleLawBot = Application.Current.Resources["ChildWindowStyleLawBot"];

    place break point and check, if "childWindowStyleLawBot" is null.
    This should clarify the problem.

    Thursday, May 19, 2011 8:05 AM
  • Hi,

    I have modified the contructor and debugged and childWindowStyleLawBot is NULL

    object childWindowStyleLawBot = Application.Current.Resources["ChildWindowStyleLawBot"];

    How do I get the Childwindow to find this resource?

    Cheer

    public ReadCodeChildWindow(Code code)
    {

                object childWindowStyleLawBot = Application.Current.Resources["ChildWindowStyleLawBot"];
               
                InitializeComponent();
                _code = code;

                CreateCode();
     }

    Thursday, May 19, 2011 8:21 AM
  • Ok, I know what is wrong.

    I am using PRISM therefore I have 2 app.xaml files. One for the shell and the other for the module.

    The resources must be added to the one in the shell not the one in the module as I was doing.

    Thanks for all your help.

    Thursday, May 19, 2011 8:41 AM
  • Actually when you're creating module which should be downloaded as separate XAP, "App.xaml" is not needed, so you can delete it.

    Thursday, May 19, 2011 8:49 AM
  • Thanks for the info

    Friday, May 20, 2011 5:14 AM