locked
ThemeBrush

    Question

  • Is there a way to access ThemeBrush (i.e. ButtonBackgroundThemeBrush) that are predefine in XAML in code?  Can you provide sample?

    eme

    Thursday, August 2, 2012 1:10 AM

Answers

  • The theme brushes are hosted in your app's resources. You can access your merged ResourceDictionary from the Page's (or App's, etc.) Resources property. See ResourceDictionary and StaticResource references for more information on how these work. You can access it from C++ as follows:

    button->Background = safe_cast<Brush^>(this->Resources->Lookup(L"ButtonBackgroundThemeBrush"));
    	

    There are examples of this in several of the samples. Mainpage.xaml.cpp in the XAML user and custom controls sample is one of them.

    --Rob

    • Proposed as answer by Jesse Jiang Thursday, August 2, 2012 7:41 AM
    • Marked as answer by Jesse Jiang Thursday, August 9, 2012 5:42 AM
    Thursday, August 2, 2012 1:41 AM
    Owner

All replies

  • The theme brushes are hosted in your app's resources. You can access your merged ResourceDictionary from the Page's (or App's, etc.) Resources property. See ResourceDictionary and StaticResource references for more information on how these work. You can access it from C++ as follows:

    button->Background = safe_cast<Brush^>(this->Resources->Lookup(L"ButtonBackgroundThemeBrush"));
    	

    There are examples of this in several of the samples. Mainpage.xaml.cpp in the XAML user and custom controls sample is one of them.

    --Rob

    • Proposed as answer by Jesse Jiang Thursday, August 2, 2012 7:41 AM
    • Marked as answer by Jesse Jiang Thursday, August 9, 2012 5:42 AM
    Thursday, August 2, 2012 1:41 AM
    Owner
  • This helped. Thank you.  

    eme

    Thursday, August 2, 2012 5:35 PM