locked
Silverlight 4 Application Wide Toolkit Theme Styles RRS feed

  • Question

  • How do I apply a toolkit theme style application wide?

    I have tried...

    <Application x:Class="MyApp.App" 
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    toolkit:ExpressionDarkTheme.IsApplicationTheme="True">

    with no result

    I have also tried this in App.xaml Application.Resources...

         <ResourceDictionary Source="/MyApp;component/System.Windows.Controls.Theming.ExpressionDark.xaml" />           

     with a Failed to assign to property 'System.Windows.ResourceDictionary.Source'.  



    Saturday, July 10, 2010 1:10 PM

Answers

  • I found a work around.

    1) goto C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Toolkit\Nov09\Themes\Xaml

    2) Grab the Xaml Theme and put it in your assets folder

    3) Link to theme in app.xaml, like so (I renamed mine to ExpressionDark.Xaml)


               <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Common;component/Converters.xaml" />
                    <ResourceDictionary Source="Assets/Navigation.xaml" />
                    <ResourceDictionary Source="Assets/Notification.xaml" />
                    <ResourceDictionary Source="Assets/FlowItemLayout.xaml" />
                    <ResourceDictionary Source="Assets/ExpressionDark.xaml" />
                </ResourceDictionary.MergedDictionaries>


    4) (This is the important step) Edit the theme, delete all the x:Name / x:Key tags


    The theme should cascade throughout the app.

    Thanks guys and girls. 

    Saturday, July 10, 2010 7:53 PM

All replies

  • Torak

    Theme  has to be on each page.  For example: 

     

    <navigation:Page x:Class="FamilyTree.Views.About"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
               xmlns:Theming="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.WhistlerBlue"
               mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
        <Grid x:Name="LayoutRoot">
            <Theming:WhistlerBlueTheme Width="Auto" Margin="0" HorizontalAlignment="Stretch">
                <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">
                    <StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">
                        <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="{Binding Path=ApplicationStrings.AboutPageTitle, Source={StaticResource ResourceWrapper}}"/>
                        <Grid Width="Auto" Height="Auto">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="10*" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                            </StackPanel>
                        </Grid>
                    </StackPanel>
                </ScrollViewer>
            </Theming:WhistlerBlueTheme>
        </Grid>
    </navigation:Page>

    Hope it helps.

    Mohan John

     

    Saturday, July 10, 2010 7:15 PM
  • That applicationtheme stuff is supposed to work too, but I couldn't get it to work either.  AND there are other problems with the themes that imho make them almost not worth using.  Like they don't include validation states for all the controls and most of the themes don't present chart legends properly. :-(

    Saturday, July 10, 2010 7:20 PM
  • I found a work around.

    1) goto C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Toolkit\Nov09\Themes\Xaml

    2) Grab the Xaml Theme and put it in your assets folder

    3) Link to theme in app.xaml, like so (I renamed mine to ExpressionDark.Xaml)


               <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Common;component/Converters.xaml" />
                    <ResourceDictionary Source="Assets/Navigation.xaml" />
                    <ResourceDictionary Source="Assets/Notification.xaml" />
                    <ResourceDictionary Source="Assets/FlowItemLayout.xaml" />
                    <ResourceDictionary Source="Assets/ExpressionDark.xaml" />
                </ResourceDictionary.MergedDictionaries>


    4) (This is the important step) Edit the theme, delete all the x:Name / x:Key tags


    The theme should cascade throughout the app.

    Thanks guys and girls. 

    Saturday, July 10, 2010 7:53 PM
  • Hello!!

    What do you mean with delete all the x:Name/ x:Key tags? what should i type instead? Or should i remove the complete block?

    Thanks in advance

    Tuesday, August 16, 2011 5:17 PM
  • I found a work around.

    ...

     

    That works because you are replacing default styles, but it doesn't really solve the problem of why the application style in your first xaml doesn't work.  I don't believe doing it that way will let you CHANGE styles dynamically either.

    Wednesday, August 17, 2011 8:45 AM