locked
How to change the background color of border and grid?

    Question

  • I want to change the background color of border and grid by C++.

    Charlie Chang L

    Wednesday, September 05, 2012 3:01 PM

Answers

  • You don't want to do this in a real app, but to hardcode a color:
    myBorder->Background = ref new SolidColorBrush(Colors::Red);
    
    Better would be to use a resource so you can use the same brush in multiple places and change them all at once for high contrast.
        <Page.Resources>
            <SolidColorBrush x:Key="MyGridBrush" Color="Red" />
        </Page.Resources>
    myGrid->Background = static_cast<Brush^>(this->Resources->Lookup("MyGridBrush"));
    
    --Rob
    • Marked as answer by Charlie C Thursday, September 06, 2012 1:05 AM
    Wednesday, September 05, 2012 7:40 PM
    Owner

All replies

  • You don't want to do this in a real app, but to hardcode a color:
    myBorder->Background = ref new SolidColorBrush(Colors::Red);
    
    Better would be to use a resource so you can use the same brush in multiple places and change them all at once for high contrast.
        <Page.Resources>
            <SolidColorBrush x:Key="MyGridBrush" Color="Red" />
        </Page.Resources>
    myGrid->Background = static_cast<Brush^>(this->Resources->Lookup("MyGridBrush"));
    
    --Rob
    • Marked as answer by Charlie C Thursday, September 06, 2012 1:05 AM
    Wednesday, September 05, 2012 7:40 PM
    Owner
  • Thanks. Help me solved an annoy bug.

    Charlie Chang L

    Thursday, September 06, 2012 1:06 AM