Home Forums WPF controls Xceed DataGrid for WPF How to set theme programmatically?

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

    Hi. I’ve been able to set my theme as Aero in Xaml by doing:

    <xcdg:DataGridControl.View>
    <xcdg:TableView Theme=”AeroNormalColorTheme”
    FixedColumnCount=”1″/>
    </xcdg:DataGridControl.View>

    I’ve built an application starting from one of the samples (SolidFoundation) where you can switch between TableView, CardView, etc. My main problem is when I switch views from Card back to Table and so on, the aero theme goes away! I may need to set the theme programmatically? How would I do that? Thanks.

    Imported from legacy forums. Posted by Brad (had 2932 views)

    Xceed Support
    Member
    Post count: 5658

    Here is a quick example. By default, the grid will use the CardView view in a Classic system-color theme. When the current item changes, the view will be changed to TableView and the same Classic system-color theme will be reapplied to the view. Hope this is what you were looking for.

    <code>
    protected override void OnInitialized( EventArgs e )
    {
    base.OnInitialized( e );

    DataGridControl grid = new DataGridControl();
    grid.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler( grid_PropertyChanged );
    grid.ItemsSource = App.PersonCollection;

    CardView view = new CardView();
    view.Theme = new ClassicSystemColorTheme();

    grid.View = view;

    this.Content = grid;
    }

    void grid_PropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
    {
    DataGridControl grid = sender as DataGridControl;

    if( grid != null )
    {
    if( e.PropertyName == “CurrentItem” )
    {
    grid.View = new TableView();
    grid.View.Theme = new ClassicSystemColorTheme();

    }
    }
    }
    </code>

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

    User (Old forums)
    Member
    Post count: 23064

    What namespace are those themes in? (ClassisSystemColorTheme, AeroNormalColorTheme, etc.)

    Imported from legacy forums. Posted by Brad (had 256 views)

    User (Old forums)
    Member
    Post count: 23064

    Nevermind… got it!

    Imported from legacy forums. Posted by Brad (had 4107 views)

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