c# - How to check for the current background color of a grid? -
i'm trying make toggle button change background color of windows phone 7 app.
i'm changing background color of grid named layoutroot using code:
layoutroot.background = new solidcolorbrush(colors.white);
after i've done that, want check value of layoutroot.background
in if statement (to serve toggle). i'm running problems. can't seem come way check value.
when layoutroot.background.tostring()
, system.windows.media.solidbrushcolor
value. suppose makes sense, since background solidbrushcolor. how access value, can check in if statement?
you can do:
solidcolorbrush brush = layoutroot.background solidcolorbrush; if (brush != null) { if (brush.color == colors.white) { // } }
other possible brushes include lineargradientbrush , radialgradientbrush, solidcolorbrush 1 of many possible brush types. why there if-statement checking null.
Comments
Post a Comment