Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.tilebrush.tilemode.aspx" rel="noreferrer"><code>TileMode</code></a> property as well as the <code>Viewport</code> and <code>ViewportUnits</code>:</p> <p>For example:</p> <pre><code>&lt;Window.Background&gt; &lt;ImageBrush ImageSource="myImage.png" Viewport="0,0,300,300" ViewportUnits="Absolute" TileMode="Tile" Stretch="None" AlignmentX="Left" AlignmentY="Top" /&gt; &lt;/Window.Background&gt; </code></pre> <p>Note: the second 2 segments of the <code>Viewport</code> attribute indicate the desired size of each repetition. If you want to display the entire image, these should be the width and height of the image.</p> <p>Example output: <img src="https://i.stack.imgur.com/qKmSi.png" alt="tiled magnifiers"></p> <p><strong>Edit in response to comments</strong></p> <p>If you don't know the size of the image to specify in the <code>Viewport</code> property, you can use a <code>Binding</code> with an <code>IValueConverter</code> to calculate it from the image. I am convinced there must be a better way of doing this, but I haven't found one yet!</p> <p>XAML:</p> <pre><code>&lt;Window.Resources&gt; &lt;local:Converter x:Key="Converter" /&gt; &lt;/Window.Resources&gt; &lt;Window.Background&gt; &lt;ImageBrush ImageSource="myImage.png" ViewportUnits="Absolute" TileMode="Tile" Stretch="None" AlignmentX="Left" AlignmentY="Top" Viewport="{Binding ImageSource, RelativeSource={RelativeSource Self}, Converter={StaticResource Converter}}"/&gt; &lt;/Window.Background&gt; </code></pre> <p>Value converter:</p> <pre><code>public class Converter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var source = (ImageSource)value; return new Rect(0,0,source.Width, source.Height); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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