Background color has no affect on canvas RRS feed

  • Question

  • I have a canvas put quite a bit of work into, and when I went to add color, it does not change the color. (The background stays as "No Brush" even though I have added a brush. I have checked the XAML code and it appears okay, but for some reason this canvas will not allow me to change its color. Here is the snippet in XAML that doesnt do anything.
    Saturday, November 21, 2009 12:33 PM

All replies

  • Can you post the XAML?  Do you get the "No Brush" error in Blend?

    Saturday, November 21, 2009 2:50 PM
  • Hi talldaniel, 

    Maybe you didn't specified your "Background" attribute properly in your xaml... 

    In your xaml try using :

    <Canvas x:Name="myMainCanvas" Width="600" Height="400" Background="Beige">
      <!-- content you want to put in between... -->

    That should do the trick.
    Of course if you enter any object like a Border that fills the whole
    Canvas space... it's obvious you will no longer see your Canvas in background. 

    If this answers your question please select Mark as an answer. Thank you!

    Saturday, November 21, 2009 2:51 PM
  • You'll also may need to explicitly set the Width and Height of your Canvas or it may end up as width and height of 0, so you wouldn't see your background.  

    Sunday, November 22, 2009 8:10 AM
  • Fury, I did post a code snippet, and something filtered it and kept it from showing. Perhaps it is Silverlight.net webhosts worrying about cross-site scripting or something. The XAML code I was trying to post was written by Expression Blend, so it is probably correctly done anyway. Any suggestions on how to keep the website Gods from filtering out the XAML so that I can post it, and it will actually show? Thanks
    Sunday, November 22, 2009 10:08 PM
  • Hi,

       Em , if you still failed to post your code block , you can upload it to skydrive.live.com. We will reproduce it and try to find you an answer.

    Best Regards

    Tuesday, November 24, 2009 5:34 AM
  • You can post XAML by using the Source Code button (last button in the text editor toolbar). Paste the xaml in the text editor and choose XML in the dropdown list.

    Tuesday, November 24, 2009 11:01 AM