Resource Not Found - Ms Control Theme

2 posts, 0 answers
  1. Mickael
    Mickael avatar
    1 posts
    Member since:
    Nov 2013

    Posted 18 Nov 2013 Link to this post

    hi,

    I have implemented a custom theme in my solution. RadControls and Ms controls works fine, but when i want to create a ms control style with the Key "HeaderGrayButton", the resource wasn't finded by the application.

    My theme (System.Windows.Button.Xaml) :

    <Style TargetType="Button">
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder_Normal}" />
            <Setter Property="Background" Value="{StaticResource ControlBackground_Normal}" />
            <Setter Property="Foreground" Value="{StaticResource ControlForeground_Normal}" />
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                             
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderBrush" >
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlOuterBorder_MouseOver}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlBackground_MouseOver}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlInnerBorder_MouseOver}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CommonStatesWrapper" Storyboard.TargetProperty="Opacity">
                                                <DiscreteDoubleKeyFrame KeyTime="00:00:00.050" Value="0" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlOuterBorder_Pressed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background" >
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlBackground_Pressed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush" >
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlInnerBorder_Pressed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"  Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity" To="1" />
                                            <DoubleAnimation Duration="0"  Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To="0.5" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStatesGroup">
                                    <VisualState x:Name="Unfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="00:00:00.150">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.150" Value="0" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                             
     
                            <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" >
                                <Border x:Name="InnerBorder" Background="{TemplateBinding Background}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        CornerRadius="{StaticResource ControlInnerBorder_CornerRadius}"
                                        BorderBrush="{StaticResource ControlInnerBorder_Normal}" />
                            </Border>
     
                            <Border x:Name="DisabledVisual" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{StaticResource ControlOuterBorder_Disabled}"
                                    CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" >
                                <Border Background="{StaticResource ControlBackground_Disabled}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        CornerRadius="{StaticResource ControlInnerBorder_CornerRadius}"
                                        BorderBrush="{StaticResource ControlInnerBorder_Disabled}" />
                            </Border>
     
                            <ContentPresenter x:Name="Content"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    Margin="{TemplateBinding Padding}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                     />
                                 
                             
                            <Border x:Name="CommonStatesWrapper">
                                    <Border x:Name="FocusVisual" Visibility="Collapsed" Opacity="0" BorderThickness="1" CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" BorderBrush="{StaticResource ControlOuterBorder_Focused}" Background="{StaticResource ControlBackground_Focused}">
                                    <Border x:Name="FocusInnerVisual" BorderThickness="1" CornerRadius="{StaticResource ControlInnerBorder_CornerRadius}" BorderBrush="{StaticResource ControlInnerBorder_Focused}"/>
                                </Border>
                            </Border>
                                 
                        </Grid>
                         
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="OpacityMask" Value="{StaticResource CoreButtonOuterBorder_Pressed}"/>
        </Style>
     
    <Style x:Key="HeaderGrayButton" TargetType="Button">
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Background" Value="Red"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="1"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <Grid.Resources>
     
                                <!-- Couleur du bouton de contenu Gris-->
                                <Color x:Key="ButtonGrayColor">#FF4E5566</Color>
     
                                <!-- Couleur du bouton de contenu Hover et Pressed Gris-->
                                <Color x:Key="ButtonGrayPressedColor">#FF4E5566</Color>
     
                                <LinearGradientBrush x:Key="ControlOuterBorder_Normal" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFFFF" />
                                    <GradientStop Color="#FFFFFF" Offset="1" />
                                </LinearGradientBrush>
                                <LinearGradientBrush x:Key="ControlBackground_Normal" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0.5" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0.5" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="1" />
                                </LinearGradientBrush>
                                <SolidColorBrush x:Key="ControlForeground_Normal" Color="#FFFFFF" />
                                <SolidColorBrush x:Key="ControlOuterBorder_MouseOver" Color="#FFFFFF" />
                                <LinearGradientBrush x:Key="ControlBackground_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0.5" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0.5" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="1" />
                                </LinearGradientBrush>
                                <LinearGradientBrush x:Key="ControlInnerBorder_MouseOver" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="1" />
                                </LinearGradientBrush>
                                <SolidColorBrush x:Key="ControlOuterBorder_Pressed" Color="#FFFFFF" />
                                <LinearGradientBrush x:Key="ControlBackground_Pressed" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{StaticResource ButtonGrayPressedColor}" Offset="0" />
                                    <GradientStop Color="{StaticResource ButtonGrayPressedColor}" Offset="0.5" />
                                </LinearGradientBrush>
                                <LinearGradientBrush x:Key="ControlInnerBorder_Pressed" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{StaticResource ButtonGrayPressedColor}" Offset="0" />
                                    <GradientStop Color="{StaticResource ButtonGrayPressedColor}" Offset="0.5" />
                                </LinearGradientBrush>
                                <CornerRadius x:Key="ControlOuterBorder_CornerRadius">0</CornerRadius>
                                <CornerRadius x:Key="ControlInnerBorder_CornerRadius">0</CornerRadius>
                                <LinearGradientBrush x:Key="ControlInnerBorder_Normal" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="0" />
                                    <GradientStop Color="{StaticResource ButtonGrayColor}" Offset="1" />
                                </LinearGradientBrush>
                                <SolidColorBrush x:Key="ControlOuterBorder_Disabled" Color="#FFD9D9D9" />
                                <SolidColorBrush x:Key="ControlBackground_Disabled" Color="#FFF8F8F8" />
                                <LinearGradientBrush x:Key="ControlInnerBorder_Disabled" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFFAFAFB" Offset="0" />
                                    <GradientStop Color="#FFF0F0F0" Offset="1" />
                                </LinearGradientBrush>
                                <SolidColorBrush x:Key="ControlOuterBorder_Focused" Color="#FFFFFF" />
                                <SolidColorBrush x:Key="ControlBackground_Focused" Color="Transparent" />
                                <SolidColorBrush x:Key="ControlInnerBorder_Focused" Color="Transparent" />
                                <SolidColorBrush x:Key="CoreButtonOuterBorder_Pressed" Color="#FFFFFF" />
     
     
                            </Grid.Resources>
     
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderBrush" >
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlOuterBorder_MouseOver}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlBackground_MouseOver}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlInnerBorder_MouseOver}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CommonStatesWrapper" Storyboard.TargetProperty="Opacity">
                                                <DiscreteDoubleKeyFrame KeyTime="00:00:00.050" Value="0" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderBrush">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlOuterBorder_Pressed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="Background" >
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlBackground_Pressed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderBrush" >
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ControlInnerBorder_Pressed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"  Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="Opacity" To="1" />
                                            <DoubleAnimation Duration="0"  Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" To="0.5" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStatesGroup">
                                    <VisualState x:Name="Unfocused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="00:00:00.150">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Collapsed</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.150" Value="0" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Opacity">
                                                <LinearDoubleKeyFrame KeyTime="00:00:00.115" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
     
     
                            <Border x:Name="OuterBorder" BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" >
                                <Border x:Name="InnerBorder" Background="{TemplateBinding Background}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        CornerRadius="{StaticResource ControlInnerBorder_CornerRadius}"
                                        BorderBrush="{StaticResource ControlInnerBorder_Normal}" />
                            </Border>
     
                            <Border x:Name="DisabledVisual" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{StaticResource ControlOuterBorder_Disabled}"
                                    CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" >
                                <Border Background="{StaticResource ControlBackground_Disabled}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        CornerRadius="{StaticResource ControlInnerBorder_CornerRadius}"
                                        BorderBrush="{StaticResource ControlInnerBorder_Disabled}" />
                            </Border>
     
                            <ContentPresenter x:Name="Content"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    Margin="{TemplateBinding Padding}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                     />
     
     
                            <Border x:Name="CommonStatesWrapper">
                                <Border x:Name="FocusVisual" Visibility="Collapsed" Opacity="0" BorderThickness="1" CornerRadius="{StaticResource ControlOuterBorder_CornerRadius}" BorderBrush="{StaticResource ControlOuterBorder_Focused}" Background="{StaticResource ControlBackground_Focused}">
                                    <Border x:Name="FocusInnerVisual" BorderThickness="1" CornerRadius="{StaticResource ControlInnerBorder_CornerRadius}" BorderBrush="{StaticResource ControlInnerBorder_Focused}"/>
                                </Border>
                            </Border>
     
                        </Grid>
     
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="OpacityMask" Value="{StaticResource CoreButtonOuterBorder_Pressed}"/>
        </Style>

    Any idea why?

    Thanks a lot,

    Mick
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 21 Nov 2013 Link to this post

    Hi Mickael,


    Since you have defined an implicit style for a Button it will be applied to all buttons in your application. 
    Your keyed style HeaderGrayButton will be applied only if you set it explicitly to this element. 

    As you mentioned by some reason this style could not be resolved, however with these style definitions we are not able to determine what might be causing such a behavior. It would be best if you isolate the problem in a small project and send it back to us as an attachment in a new support thread. 

    Have a great day! 

    Regards,
    Vanya Pavlova
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top