Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - ImageBrush TileMode not working?

 
 
Old 01-10-2006   #1 (permalink)
Corrado Cavalli [MVP]


 
 

ImageBrush TileMode not working?

I have following markup

<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition/>

</Grid.ColumnDefinitions>
<Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
<Rectangle.Fill>
<ImageBrush ImageSource="\Resources\ferrari.jpg" Stretch="Uniform"
TileMode="Tile"/>
</Rectangle.Fill>
</Rectangle>
</Grid>

But can't see image tiled, it just appears centered...
Am i missing something?


--
Corrado Cavalli [Microsoft .NET MVP-MCP]
UGIdotNET - http://www.ugidotnet.org
Weblog: http://blogs.ugidotnet.org/corrado




My System SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
Adam Smith [MS]


 
 

Re: ImageBrush TileMode not working?

By default, the Viewport for a TileBrush is 0,0,1,1 and the ViewportUnits
are RelativeToBoundingBox, meaning that 0,0,1,1 maps to the entire
destination size (in this case, the bounds of the Rectangle Element). When
tiling a TileBrush, it's the Viewport which is repeated, so since one
Viewport is taking up the entire destination size, you won't see a different
between and of the different TileModes. If you were to set the Viewport to
0,0,.5,.5, you should see 2 x 2 (since each tile will be 50%x50% the size of
the Rectangle), or 0,0,0.25,0.1 would produce a 4x10 tiling, etc.

-Adam Smith [MS]


"Corrado Cavalli [MVP]" <corradoNOSPAMPLEASE@mvps.org> wrote in message
news:40akmmF191k8cU1@individual.net...
>I have following markup
>
> <Grid>
> <Grid.RowDefinitions>
> <RowDefinition/>
> <RowDefinition/>
> </Grid.RowDefinitions>
> <Grid.ColumnDefinitions>
> <ColumnDefinition Width="Auto"/>
> <ColumnDefinition/>
> <ColumnDefinition/>
>
> </Grid.ColumnDefinitions>
> <Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
> <Rectangle.Fill>
> <ImageBrush ImageSource="\Resources\ferrari.jpg" Stretch="Uniform"
> TileMode="Tile"/>
> </Rectangle.Fill>
> </Rectangle>
> </Grid>
>
> But can't see image tiled, it just appears centered...
> Am i missing something?
>
>
> --
> Corrado Cavalli [Microsoft .NET MVP-MCP]
> UGIdotNET - http://www.ugidotnet.org
> Weblog: http://blogs.ugidotnet.org/corrado
>
>
>



My System SpecsSystem Spec
Old 01-10-2006   #3 (permalink)
craig kelly-soens www.XpectWorld.com


 
 

RE: ImageBrush TileMode not working?

hi,

I had this, i did a post but no-one answered but i figured it out in the end
myself.

If you see the rotating 360o image in the top of example below using the
<ImageBrush feature from Sept05 ctp in

C:\Program Files\Microsoft
SDKs\WinFX\samples\Allsamples\WPF\GraphicsMM_Brushes\UsingImageBrush\XAML\InteractiveExample.xaml

i used this to tile and 360 rotate a fairly small logo for the XAML client i
was working for, now in CTP sept 05 the same markup is just a column not
what i would call a tile ? I believe this is what you have also.

You will also notice that if u do a TileMode="Tile" and *dont* specify
Stretch="None" it tiles it as it did before,
but obviously the image is too "FAT" as it is stretched.

to make it look like it was with sep05 and to solve your problem, i now need
to specify viewport ?
(Viewport="0,0,70,70" ViewportUnits="Absolute")

here is the altered XAML based on nov05 CTP sample

<!-- for Animated image header -->
<Style x:Key="myAnimatedRectangleStyle">
<Style.Triggers>
<EventTrigger RoutedEvent="Rectangle.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard SpeedRatio="0.20">
<RectAnimation To="0,0,0.5,0.5" Duration="0:0:50"
RepeatBehavior="Forever" AutoReverse="True"
Storyboard.TargetProperty="(Rectangle.Fill).(ImageBrush.Viewport)" />
<DoubleAnimation To="360" Duration="0:0:50" RepeatBehavior="Forever"
AccelerationRatio="0.5" DecelerationRatio="0.5"

Storyboard.TargetProperty="(Rectangle.Fill).(ImageBrush.Transform).(RotateTransform.Angle)" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
<!-- this is for the Animated image header -->
<Setter Property="Rectangle.Fill">
<Setter.Value>
<ImageBrush ImageSource="images\CompanyLogo.jpg"
Viewport="0,0,70,70" ViewportUnits="Absolute"
Opacity="0.3" TileMode="Tile" >
<ImageBrush.Transform>
<RotateTransform Angle="0" />
</ImageBrush.Transform>
</ImageBrush>
</Setter.Value>
</Setter>
</Style>

craig kelly-soens - Windows Vista WinFx XAML .Net Evangelist
http://www.XpectWorld.com - customised "super-easy to use" Windows Vista
based software & consultancy
My System SpecsSystem Spec
Old 01-10-2006   #4 (permalink)
Corrado Cavalli [MVP]


 
 

Re: ImageBrush TileMode not working?

Thanks Adam.


--
Corrado Cavalli [Microsoft .NET MVP-MCP]
UGIdotNET - http://www.ugidotnet.org
Weblog: http://blogs.ugidotnet.org/corrado



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Binding an ImageBrush Problem .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46