(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Forums

Search in:

Go

Why explicit Style defined in a theme Which had been applied for one control aren't update when change the Theme ?.

  • jecaestevez
    Jesus Estevez
    0 points
    0 posts
    Jan 25, 2012, 08:00 PM
        Report Abuse
    Why explicit Style defined in a theme Which had been applied for one control aren't  update when change the Theme ?.

    Main.xaml: (This is a resume of main.xaml , to see full have a look the attached file)

    <UserControl>
        <Grid x:Name="LayoutRoot" Background="White" >
            <!--[PROBLEM]: This Border Style doesn't refresh when the Theme changed-->
            <Border Style="{StaticResource BorderStyle2}">
                <Button Click="Change_to_Dark_Click"
                            Height="20">Select Dark Theme</Button>
            </Border>
        </Grid>
    </UserControl>


    Main.xaml.cs : (This is a resume of main.xaml.cs, to see full have a look the attached file)
           private void Change_to_Dark_Click(object sender, RoutedEventArgs e)
            {
                //Cleannig
                App.Current.Resources.Clear();
                App.Current.Resources.MergedDictionaries.Clear();
                Theme.SetApplicationThemeUri(App.Current, null);

                Uri themeUri = new Uri("/Controls.Dark;component/Generic.xaml", UriKind.RelativeOrAbsolute);
                Theme.SetApplicationThemeUri(Application.Current, themeUri);
            //The theme changed but the style of Border doesn't change.
        }

    There is a Controls project "Controls.csproj" (to see full have a look the attached file) with:
    Generic.xaml
    Style.xaml
    ButtonCustomized.xaml

    There are 2 themes projects  created like this "Controls.Dark.csproj" (to see full have a look the attached file):
    Generic.xaml
    Style.xaml

    Generic.xaml

    <ResourceDictionary
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:controls="clr-namespace:Controls;assembly=Controls">
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Controls.Dark;component/Style.xaml" />
            <ResourceDictionary Source="/Controls;component/Themes/ButtonCustomized.xaml" />
        </ResourceDictionary.MergedDictionaries>

    </ResourceDictionary>

    Style.xaml

    <ResourceDictionary
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Color x:Key="KeyColor">#FDB800</Color>
        <Color x:Key="KeyColor2">#FBD8AB</Color>
        <SolidColorBrush x:Key="KeyColorBrush"
                         Color="{StaticResource KeyColor}" />
        <SolidColorBrush x:Key="KeyColorBrush2"
                         Color="{StaticResource KeyColor2}" />
        
        <Style x:Key="BorderStyle1"
               TargetType="Border">
            <Setter Property="Background"
                    Value="{StaticResource KeyColorBrush}" />
        </Style>

        <Style x:Key="BorderStyle2"
               TargetType="Border">
            <Setter Property="Background"
                    Value="{StaticResource KeyColorBrush2}" />
        </Style>
    </ResourceDictionary>

    I don't know why the explicit style doesn't are updates when change theme of the application?

    Thanks for the future answers, regards.

    http://silverlight.codeplex.com/workitem/10224
    Attached
    Theme-SetApplicationThemeUri.sflb
    Reply
There are no posts in this thread.

    To reply to this thread you must Log In to your account


    Thread


    Tags: 
    theme ,
    style ,
    xaml
    • Asked
      802 days ago
    • Viewed
      457
    • Last Activity
      802 days ago

    Related Threads

    • Silverlight Visual Studio 2010 Designer is Slow
    • New article series by Gill Cleeren: Windows 8 and the future of XAML. Any additional topics you need covered in this series?

    Shortcuts