background of scrollviewer control in winrt metro style apps RRS feed

  • Question

  •  i have a scrollviewer control (300x300pixels) in xaml , its "BackGround" can set only one color, but i want its background is filled by gray plaid and write plaid are alternating  alternately.how to do that?


    -- King Star



    Saturday, February 25, 2012 9:45 AM


  • The Background can be any brush. It is not limited to being a single color. If you have your plaid in an image you can use an ImageBrush:

            <ScrollViewer Height="300" Width="300">             <ScrollViewer.Background>
                    <ImageBrush ImageSource="/Images/plaid.png" Stretch="Fill">

    That said, I suspect you don't really want the plaid on the background but want the alternating colors on elements within the ScrollViewer. For that you would need a collection control and a DataTemplate which alternated its Background based on index. If you search on Alternating Rows Silverlight you should find several posts where people discuss how to do this in Silverlight. The general idea will be the same.


    Tuesday, February 28, 2012 12:31 AM