Note that there are some explanatory texts on larger screens.

plurals
  1. POAdjust the size of a XAML Grid.Background Image
    text
    copied!<p>I have a simple piece of XAML that lays out a group of tiles, each with a background image icon. </p> <pre><code> &lt;Grid.Background&gt; &lt;ImageBrush Stretch="None" ImageSource="{Binding ImageSource}" AlignmentY="Center" AlignmentX="Center"/&gt; &lt;/Grid.Background&gt; </code></pre> <p>This works fine, except the background image fills the square perfectly. I'm sure XAML thinks this is fine, but actually it needs to be about half the size to match spec.</p> <p>I tried several things including adding a border to the grid (which truncates the background image, keeping the dimensions but cutting it off on the sides and top) and adding margins and paddings in various places.</p> <p>I also played with making this a normal but everything floats over top of this background image so that is not an option. </p> <p>Finally I should mention this is a Windows 8 Windows Store app using Windows Runtime, so certain features in WPF aren't available to me here (like ViewPort).</p> <p>Question: how do you adjust the size/dimensions of a XAML grid background image? </p> <p>Sidenote: I think the solution may lie in a transform... ? </p> <p>Update: per poster request here is what the expected result should be. Even though it appears no float over the background image takes place here, in other places text floats over the background. That is why it needs to be a and not an element.</p> <p>How it looks now:</p> <p><img src="https://i.stack.imgur.com/labmy.jpg" alt="Current background image"></p> <p>How it should look:</p> <p><img src="https://i.stack.imgur.com/t2A09.jpg" alt="How I want it to look"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload