Home Forums WPF controls Xceed DataGrid for WPF Office Themes

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26993 |

    I’m new to the Xceed DataGrid WPF and was wondering if there is an easy way to apply the Office2007 Themes?  I found the Themes folder but I’m not sure if there is the “standard” Blue, Silver and Black available.  Is there sample code for the Office themes or do I need to generate it?

    Thanks

    Imported from legacy forums. Posted by William (had 1329 views)

    Xceed Support
    Member
    Post count: 5658

    The Office themes are located in the ThemePack assemblies (Xceed.Wpf.DataGrid.ThemePack.[#].dll), which must be included in your references. You can then apply them to the grid by setting the View.Theme property using property element syntax:

    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid“>
      <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key=”cvs_orders”
                                         Source=”{Binding Source={x:Static Application.Current},
                                                          Path=Orders}”/>
      </Grid.Resources>
       <xcdg:DataGridControl x:Name=”OrdersGrid”
                             ItemsSource=”{Binding Source={StaticResource cvs_orders}}”>

         <xcdg:DataGridControl.View>
            <xcdg:CardView>
               <xcdg:CardView.Theme>
                  <xcdg:Office2007BlueTheme/>
               </xcdg:CardView.Theme>
            </xcdg:CardView>
         </xcdg:DataGridControl.View>
       </xcdg:DataGridControl>
    </Grid>

    You can look in the documentation under Basic Concepts\Appearance\Views and Themes for a list of the theme names. Also note that the themes located in the theme packs require a Pro license key (either trial or registered).

    Imported from legacy forums. Posted by Jenny [Xceed] (had 2704 views)

    User (Old forums)
    Member
    Post count: 23064

    Can you tell me how to get something like this to work (or maybe it can’t be done). I do have both themepacks referenced in the project.

    <Style TargetType=”{x:Type xcdg:TableView}”>

    <!–<Setter Property=”Theme” Value=”AeroNormalColorTheme”/>–>

    <Setter Property=”Theme” Value=”Office2007BlueTheme”/>

    </Style>

     

    The error I get:

    Cannot convert string ‘Office2007BlueTheme’ in attribute ‘Theme’ to object of type ‘Xceed.Wpf.DataGrid.Views.Theme’. The specified theme is invalid.

    Parameter name: value Error at object ‘System.Windows.Setter’ in markup file ‘Skins/DefaultSkin.xaml’ Line 534 Position 34.

    Imported from legacy forums. Posted by Marty (had 1244 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi there,

    I do that in code and let the user decide what theme he/she wants.  (Just make sure that you set your datagrid to a initial theme.)

     

            private void ComboBox_Theme_Selector_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                if (ComboBox_Theme_Selector.SelectedIndex == 0)
                {
                    dgc1.View.Theme = null;
                }

                if (ComboBox_Theme_Selector.SelectedIndex == 1)
                {
                    dgc1.View.Theme = new Xceed.Wpf.DataGrid.ThemePack.WMP11Theme();
                }
                if (ComboBox_Theme_Selector.SelectedIndex == 2) 
                {
                    dgc1.View.Theme = new Xceed.Wpf.DataGrid.ThemePack.GlassTheme();
                }

                if (ComboBox_Theme_Selector.SelectedIndex == 3) 
                {
                    dgc1.View.Theme = new Xceed.Wpf.DataGrid.ThemePack.Office2007BlackTheme();
                }

                if (ComboBox_Theme_Selector.SelectedIndex == 4) 
                {
                    dgc1.View.Theme = new Xceed.Wpf.DataGrid.ThemePack.Office2007BlueTheme();
                }

                if (ComboBox_Theme_Selector.SelectedIndex == 5) 
                {
                    dgc1.View.Theme = new Xceed.Wpf.DataGrid.ThemePack.Office2007SilverTheme();
                }
               

               
            }

    Imported from legacy forums. Posted by David (had 548 views)

    Xceed Support
    Member
    Post count: 5658

    Appropriate syntax is:

    <Style TargetType=”{x:Type xcdg:TableView}”>
        <Setter Property=”Theme”>
            <Setter.Value>
                <xcdg:Office2007BlueTheme/>
            </Setter.Value>
        </Setter>
    </Style>

    This is because the ThemeConverter class that does the default string-to-theme conversion is located in the main DataGrid assembly and we did not wanted to add dependencies on the ThemePacks to the DataGrid assembly.
     

     

    Imported from legacy forums. Posted by Marcus [Xceed] (had 1344 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.