Permalink
Browse files

Added thumbstyle that demonstrates the use of Visuals of controls.

  • Loading branch information...
1 parent 982149f commit 98f86c6fdaf3b403ed5a76d3ee97c45c6f6647b4 Thorsten Lorenz committed Aug 2, 2010
Showing with 49 additions and 19 deletions.
  1. +49 −19 ResizingControls/Window1.xaml
@@ -2,11 +2,10 @@
<Window
x:Class="ResizingControls.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:interactive="clr-namespace:Shared.InteractiveBehaviors;assembly=Shared"
- xmlns:attached="clr-namespace:Shared.AttachedBehaviors;assembly=Shared"
+ xmlns:attached="clr-namespace:Shared.AttachedBehaviors;assembly=Shared"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
-
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:interactive="clr-namespace:Shared.InteractiveBehaviors;assembly=Shared"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="700"
Height="500"
Background="Beige"
@@ -18,22 +17,22 @@
<Setter Property="MaxWidth" Value="600"/>
<Setter Property="MinHeight" Value="30"/>
<Setter Property="MinWidth" Value="100"/>
- <Setter Property="Width" Value="100" />
- <Setter Property="Height" Value="50" />
+ <Setter Property="Width" Value="100"/>
+ <Setter Property="Height" Value="50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Background" Value="AntiqueWhite"/>
- <Setter Property="ContentTemplate">
- <Setter.Value>
- <DataTemplate>
- <Viewbox Stretch="Fill">
- <TextBlock Text="{TemplateBinding Content}"/>
- </Viewbox>
- </DataTemplate>
- </Setter.Value>
- </Setter>
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <Viewbox Stretch="Fill">
+ <TextBlock Text="{TemplateBinding Content}"/>
+ </Viewbox>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
</Style>
- <Style x:Key="resizeThumbStyle" TargetType="{x:Type Thumb}">
+ <Style x:Key="resizeThumbCustomStyle" TargetType="{x:Type Thumb}">
<Setter Property="Width" Value="12"/>
<Setter Property="Height" Value="12"/>
<Setter Property="Cursor" Value="SizeNWSE"/>
@@ -55,6 +54,37 @@
</Setter.Value>
</Setter>
</Style>
+ <Style x:Key="resizeThumbVisualStyle" TargetType="{x:Type Thumb}">
+ <Setter Property="Width" Value="12"/>
+ <Setter Property="Height" Value="12"/>
+ <Setter Property="Cursor" Value="SizeNWSE"/>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate>
+ <Image Width="12" Height="12">
+ <Image.Source>
+ <DrawingImage>
+ <DrawingImage.Drawing>
+ <GeometryDrawing Geometry="M9,0 L11,0 11,11 0,11 0,9 3,9 3,6 6,6 6,3 9,3z">
+ <GeometryDrawing.Brush>
+ <VisualBrush>
+ <VisualBrush.Visual>
+ <ComboBox />
+ </VisualBrush.Visual>
+ </VisualBrush>
+ </GeometryDrawing.Brush>
+ </GeometryDrawing>
+ </DrawingImage.Drawing>
+ </DrawingImage>
+ </Image.Source>
+ <Image.RenderTransform>
+ <TranslateTransform X="-8" Y="-8"/>
+ </Image.RenderTransform>
+ </Image>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
@@ -64,13 +94,13 @@
<GroupBox Grid.Row="0" Header="Attached Behaviors">
<Label
attached:ResizeAttachedBehavior.IsResizeable="true"
- attached:ResizeAttachedBehavior.ThumbStyle="{StaticResource resizeThumbStyle}"
+ attached:ResizeAttachedBehavior.ThumbStyle="{StaticResource resizeThumbCustomStyle}"
Content="ResizeMe"/>
</GroupBox>
<GroupBox Grid.Row="1" Header="Interactive Behaviors">
- <Label Content="ResizeMe" >
+ <Label Content="ResizeMe">
<i:Interaction.Behaviors>
- <interactive:ResizeInteractiveBehavior ThumbStyle="{StaticResource resizeThumbStyle}"/>
+ <interactive:ResizeInteractiveBehavior ThumbStyle="{StaticResource resizeThumbVisualStyle}"/>
</i:Interaction.Behaviors>
</Label>
</GroupBox>

0 comments on commit 98f86c6

Please sign in to comment.