Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8502253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:25:59+00:00 2026-06-11T01:25:59+00:00

Why would my VisualBrush render a lovely image in my button with this code:

  • 0

Why would my VisualBrush render a lovely image in my button with this code:

<Button>
    <Rectangle Width="28" Height="28">
        <Rectangle.Fill>
            <VisualBrush Stretch="Fill" Visual="{StaticResource lovely_image}" />
        </Rectangle.Fill>
    </Rectangle>
</Button>

But render nothing with this code?:

<Button>
    <Rectangle Width="28" Height="28">
        <Rectangle.Style>
            <Style TargetType="{x:Type Rectangle}">
               <Setter Property="Fill">
                    <Setter.Value>
                        <VisualBrush Stretch="Fill" Visual="{StaticResource lovely_image}" />                               
                    </Setter.Value>
                </Setter>
            </Style>
        </Rectangle.Style>
    </Rectangle>
</Button>

Interestingly, if I replace the VisualBrush in the second example with a SolidColorBrush, the SolidColorBrush renders.

(Why am I doing this? I’m trying to use DataTriggers to swap icons based on values in my ViewModel.)

Update

So it seems that this code works just fine. My problem was actually some weirdness in the way my resources which define my visual. The visual used a brush dynamic resource which was being loaded from a referenced assembly. This worked with the first example above, but for some reason wouldn’t for the second example. I just copied the brush into a resource in my projects assembly and viola!, my lovely_image is rendered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:26:00+00:00Added an answer on June 11, 2026 at 1:26 am

    A SolidColorBrush is abstract and can be used in multiple places. A visual is not, it can only have one parent.

    You can try x:Shared="false" on the visual in the resources. Or use the Button.ContentTemplate to make the button create multiple Rectangles (inline the visual & Content needs to be set to something for it to apply).

    Also if this is not about multiple instances as the code in your question is fine: Mind dependency property value precedence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would you write this code any differently? I don't mind tertiary operator by the
Would like to know how I can improve this code to enable no page
Would be possible to extend this kind of layout so that I can have
Would love some opinions on this problem I'm trying to workout. I'm trying to
Would you prefer this: def add(a, b) puts ADDING #{a} + #{b} return a
Would someone a little smarter than myself be able to help me with this
Would this be possible? I've used this to insert the date into a field
Would it be possible to show an image in full screen mode using silverlight.
Would having a nice little feature that makes it quicker to write code like
Would you say this is the most optimal way of doing simple traditional logging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.