This control template works great in App.xaml but locks IE in usercontrol.xaml - why?
Last post 05-11-2008 10:02 PM by sladapter. 3 replies.
Sort Posts:
05-11-2008 6:37 PM
This control template works great in App.xaml but locks IE in usercontrol.xaml - why?

The following slider styles  originated from Brad Abrams blog and Corrina Barber

http://blogs.msdn.com/brada/archive/2008/03/12/great-new-silverlight-control-skins.aspx

http://blogs.msdn.com/corrinab/archive/2008/03/11/silverlight-2-control-skins.aspx

They work great in my sl2 app when the resources are in App.xaml... however I need them in my user control resources to be able to share them without forcing updates to a persons app.xaml each time. When I move this code over IE locks up and will not load page timing out and asks you to close the program etc.

What is causing this to occur ? I tried commenting out lines etc but nothing obvious came to light..

I tried to post to the Brads blog but it is not taking posts from me for some reason...

 

 

<Style x:Key="sliderStyle" TargetType="Slider">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="Slider">

<Grid x:Name="RootElement">

<Grid.Resources>

<Storyboard x:Name="Normal State">

<DoubleAnimation Duration="0:0:0" Storyboard.TargetName="RootElement" Storyboard.TargetProperty="Opacity" To="1" />

</Storyboard>

<Storyboard x:Name="MouseOver State">

<DoubleAnimation Duration="0:0:0" Storyboard.TargetName="RootElement" Storyboard.TargetProperty="Opacity" To="1" />

</Storyboard>

<Storyboard x:Name="Disabled State">

<DoubleAnimation Duration="0:0:0" Storyboard.TargetName="RootElement" Storyboard.TargetProperty="Opacity" To="0.5" />

</Storyboard>

<ControlTemplate x:Key="RepeatButtonTemplate">

<Grid x:Name="RootElement" Background="Transparent" Opacity="0" >

<Border CornerRadius="5" Width="22" Height="22" BorderBrush="Blue" BorderThickness="2" />

</Grid>

</ControlTemplate>

</Grid.Resources>

<Grid x:Name="HorizontalTemplateElement">

<Grid.ColumnDefinitions>

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<Rectangle Stroke="#FF888888" StrokeThickness="0.5" Fill="Red" Grid.Column="0" Grid.ColumnSpan="3" Height="1.5" RadiusX="0.5" RadiusY="0.5" />

<RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButtonElement" Grid.Column="0" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

<Thumb x:Name="HorizontalThumbElement" Margin="0,6,0,0" Height="20" Width="20" Grid.Column="1" Style="{StaticResource thumbStyle}"/>

<RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButtonElement" Grid.Column="2" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

</Grid>

<Grid x:Name="VerticalTemplateElement" Visibility="Collapsed">

<Grid.RowDefinitions>

<RowDefinition Height="*" />

<RowDefinition Height="Auto" />

<RowDefinition Height="Auto" />

</Grid.RowDefinitions>

<Rectangle Stroke="Black" StrokeThickness="0.5" Fill="#FFE6EFF7" Grid.Row="0" Grid.RowSpan="3" Width="3"/>

<RepeatButton x:Name="VerticalTrackLargeChangeDecreaseRepeatButtonElement" Grid.Row="2" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

<Thumb x:Name="VerticalThumbElement" Height="20" Width="20" Grid.Row="1" Style="{StaticResource thumbStyle}"/>

<RepeatButton x:Name="VerticalTrackLargeChangeIncreaseRepeatButtonElement" Grid.Row="0" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

</Grid>

<Rectangle x:Name="FocusVisualElement" Stroke="#FF999999" StrokeThickness=".75" StrokeDashArray="1 2" StrokeDashCap="Square" IsHitTestVisible="false" />

</Grid>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

<!--SliderStyle + SliderThumbStyle-->

<Style x:Key="sliderStyle" TargetType="Slider">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="Slider">

<Grid x:Name="RootElement">

<Grid.Resources>

<Storyboard x:Name="Normal State">

<DoubleAnimation Duration="0:0:0" Storyboard.TargetName="RootElement" Storyboard.TargetProperty="Opacity" To="1" />

</Storyboard>

<Storyboard x:Name="MouseOver State">

<DoubleAnimation Duration="0:0:0" Storyboard.TargetName="RootElement" Storyboard.TargetProperty="Opacity" To="1" />

</Storyboard>

<Storyboard x:Name="Disabled State">

<DoubleAnimation Duration="0:0:0" Storyboard.TargetName="RootElement" Storyboard.TargetProperty="Opacity" To="0.5" />

</Storyboard>

<ControlTemplate x:Key="RepeatButtonTemplate">

<Grid x:Name="RootElement" Background="Transparent" Opacity="0" >

<!--<Border CornerRadius="5" Width="22" Height="22" BorderBrush="Blue" BorderThickness="2" />-->

</Grid>

</ControlTemplate>

</Grid.Resources>

<Grid x:Name="HorizontalTemplateElement">

<Grid.ColumnDefinitions>

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<Rectangle Stroke="#FF888888" StrokeThickness="1" Fill="Red" Grid.Column="0" Grid.ColumnSpan="3" Height="3.5" RadiusX="0.5" RadiusY="0.5" />

<RepeatButton x:Name="HorizontalTrackLargeChangeDecreaseRepeatButtonElement" Grid.Column="0" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

<Thumb x:Name="HorizontalThumbElement" Margin="0,6,0,0" Height="20" Width="20" Grid.Column="1" Style="{StaticResource thumbStyle}"/>

<RepeatButton x:Name="HorizontalTrackLargeChangeIncreaseRepeatButtonElement" Grid.Column="2" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

</Grid>

<Grid x:Name="VerticalTemplateElement" Visibility="Collapsed">

<Grid.RowDefinitions>

<RowDefinition Height="*" />

<RowDefinition Height="Auto" />

<RowDefinition Height="Auto" />

</Grid.RowDefinitions>

<Rectangle Stroke="Black" StrokeThickness="0.5" Fill="#FFE6EFF7" Grid.Row="0" Grid.RowSpan="3" Width="3"/>

<RepeatButton x:Name="VerticalTrackLargeChangeDecreaseRepeatButtonElement" Grid.Row="2" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

<Thumb x:Name="VerticalThumbElement" Height="20" Width="20" Grid.Row="1" Style="{StaticResource thumbStyle}"/>

<RepeatButton x:Name="VerticalTrackLargeChangeIncreaseRepeatButtonElement" Grid.Row="0" Template="{StaticResource RepeatButtonTemplate}" IsTabStop="False" />

</Grid>

<Rectangle x:Name="FocusVisualElement" Stroke="#FF999999" StrokeThickness=".75" StrokeDashArray="1 2" StrokeDashCap="Square" IsHitTestVisible="false" />

</Grid>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

<Style x:Key="thumbStyle" TargetType="Thumb">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="Thumb">

<Grid x:Name="RootElement">

<Grid.Resources>

<Storyboard x:Name="Normal State">

<ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="00:00:00.02">

<SplineColorKeyFrame KeyTime="00:00:00" Value="#FF888888"/>

</ColorAnimationUsingKeyFrames>

</Storyboard>

<Storyboard x:Name="MouseOver State">

<ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="00:00:00.02">

<SplineColorKeyFrame KeyTime="00:00:00" Value="#BBFFFFFF"/>

</ColorAnimationUsingKeyFrames>

</Storyboard>

<Storyboard x:Name="Pressed State">

<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ScalableBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" BeginTime="00:00:00" Duration="00:00:00.02">

<SplineDoubleKeyFrame KeyTime="00:00:00" Value=".5"/>

</DoubleAnimationUsingKeyFrames>

<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ScalableBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" BeginTime="00:00:00" Duration="00:00:00.02">

<SplineDoubleKeyFrame KeyTime="00:00:00" Value=".5"/>

</DoubleAnimationUsingKeyFrames>

<ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" BeginTime="00:00:00" Duration="00:00:00.02">

<SplineColorKeyFrame KeyTime="00:00:00" Value="#BBFFFFFF"/>

</ColorAnimationUsingKeyFrames>

</Storyboard>

<Storyboard x:Name="Disabled State">

<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Disabled" Storyboard.TargetProperty="(UIElement.Opacity)" BeginTime="00:00:00" Duration="00:00:00.02">

<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.7"/>

</DoubleAnimationUsingKeyFrames>

</Storyboard>

</Grid.Resources>

<Border x:Name="ScalableBorder" RenderTransformOrigin="0.5,0.5">

<Border.RenderTransform>

<TransformGroup>

<ScaleTransform ScaleY="-1"/>

<SkewTransform/>

<RotateTransform/>

<TranslateTransform/>

</TransformGroup>

</Border.RenderTransform>

<Grid Cursor="Hand">

<Path x:Name="BackgroundShadow1" Stretch="Fill" Stroke="#FF000000" StrokeThickness="2" Fill="#FF000000" Margin="-2" Opacity=".05" Data="M20.747934,1.5 L52.092117,1.5 C52.250446,1.5000001 53.737717,2.7400134 53.737717,3.1673 L53.737717,25.5 C53.737717,27.709139 52.209141,29.5 50,29.5 L46.235802,29.5 C43.564945,33.395603 36.190704,43.5 31.75,43.5 C27.309294,43.5 19.935053,33.395603 17.2642,29.5 L13.5,29.5 C11.290861,29.5 9.5,27.709139 9.5,25.5 L9.5,10.805009 C9.5,4.6463528 15.468018,1.5000001 20.747934,1.5" />

<Path x:Name="BackgroundShadow2" Stretch="Fill" Stroke="#FF000000" StrokeThickness="2" Fill="#FF000000" Margin="-1" Opacity=".05" Data="M20.747934,1.5 L52.092117,1.5 C52.250446,1.5000001 53.737717,2.7400134 53.737717,3.1673 L53.737717,25.5 C53.737717,27.709139 52.209141,29.5 50,29.5 L46.235802,29.5 C43.564945,33.395603 36.190704,43.5 31.75,43.5 C27.309294,43.5 19.935053,33.395603 17.2642,29.5 L13.5,29.5 C11.290861,29.5 9.5,27.709139 9.5,25.5 L9.5,10.805009 C9.5,4.6463528 15.468018,1.5000001 20.747934,1.5" />

<Path x:Name="BackgroundShadow3hood" Stretch="Fill" Stroke="#FF000000" StrokeThickness="4" Fill="Red" Margin="-1" Opacity=".5" Data="M20.747934,1.5 L252.092117,1.5 " />

<Path x:Name="Background" Stretch="Fill" Stroke="#FF888888" StrokeThickness="1.5" Data="M20.747934,1.5 L52.092117,1.5 C52.250446,1.5000001 53.737717,2.7400134 53.737717,3.1673 L53.737717,25.5 C53.737717,27.709139 52.209141,29.5 50,29.5 L46.235802,29.5 C43.564945,33.395603 36.190704,43.5 31.75,43.5 C27.309294,43.5 19.935053,33.395603 17.2642,29.5 L13.5,29.5 C11.290861,29.5 9.5,27.709139 9.5,25.5 L9.5,10.805009 C9.5,4.6463528 15.468018,1.5000001 20.747934,1.5">

<Path.Fill>

<LinearGradientBrush StartPoint="0.7,0" EndPoint="0.7,1">

<GradientStop x:Name="LinearBevelLightStart1" Color="#FFDAB9B9" Offset="0" />

<GradientStop x:Name="LinearBevelLightEnd1" Color="#FFE6CBCB" Offset="0.3" />

<GradientStop x:Name="LinearBevelDarkStart1" Color="#FFC8A1A1" Offset="0.3" />

<GradientStop x:Name="LinearBevelDarkEnd1" Color="#FF5B0000" Offset="1" />

</LinearGradientBrush>

</Path.Fill>

</Path>

<Path x:Name="BorderTransparency" Margin="0.5" Opacity="0.35" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="2.5" Data="M20.747934,1.5 L52.092117,1.5 C52.250446,1.5000001 53.737717,2.7400134 53.737717,3.1673 L53.737717,25.5 C53.737717,27.709139 52.209141,29.5 50,29.5 L46.235802,29.5 C43.564945,33.395603 36.190704,43.5 31.75,43.5 C27.309294,43.5 19.935053,33.395603 17.2642,29.5 L13.5,29.5 C11.290861,29.5 9.5,27.709139 9.5,25.5 L9.5,10.805009 C9.5,4.6463528 15.468018,1.5000001 20.747934,1.5"/>

<Path x:Name="FocusVisualElement" Margin="3" Visibility="Collapsed" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="0.75" Data="M20.747934,1.5 L52.092117,1.5 C52.250446,1.5000001 53.737717,2.7400134 53.737717,3.1673 L53.737717,25.5 C53.737717,27.709139 52.209141,29.5 50,29.5 L46.235802,29.5 C43.564945,33.395603 36.190704,43.5 31.75,43.5 C27.309294,43.5 19.935053,33.395603 17.2642,29.5 L13.5,29.5 C11.290861,29.5 9.5,27.709139 9.5,25.5 L9.5,10.805009 C9.5,4.6463528 15.468018,1.5000001 20.747934,1.5"/>

<Path x:Name="Disabled" Stretch="Fill" Stroke="#FFFFFFFF" StrokeThickness="2" Fill="#FFFFFFFF" Opacity="0" Data="M20.747934,1.5 L52.092117,1.5 C52.250446,1.5000001 53.737717,2.7400134 53.737717,3.1673 L53.737717,25.5 C53.737717,27.709139 52.209141,29.5 50,29.5 L46.235802,29.5 C43.564945,33.395603 36.190704,43.5 31.75,43.5 C27.309294,43.5 19.935053,33.395603 17.2642,29.5 L13.5,29.5 C11.290861,29.5 9.5,27.709139 9.5,25.5 L9.5,10.805009 C9.5,4.6463528 15.468018,1.5000001 20.747934,1.5"/>

</Grid>

</Border>

</Grid>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

oohogwash

Joined on 10-22-2007
Posts 8
05-11-2008 9:01 PM
Re: This control template works great in App.xaml but locks IE in usercontrol.xaml - why?

 You have two style have the same x:Key:

<Style x:Key="sliderStyle" TargetType="Slider">

 And

<!--SliderStyle + SliderThumbStyle-->

<Style x:Key="sliderStyle" TargetType="Slider">

 

 

Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

sladapter

Joined on 03-05-2008
Indiana, US
Posts 404
05-11-2008 9:44 PM
Re: Re: This control template works great in App.xaml but locks IE in usercontrol.xaml - why?

sorry I deleted the prefix of that entry, which was test.

oohogwash

Joined on 10-22-2007
Posts 8
05-11-2008 10:02 PM
Marked as Answer
Re: Re: This control template works great in App.xaml but locks IE in usercontrol.xaml - why?

What do you mean? What prefix you are talking about. You have it working now?

If I remove one <Style x:Key="sliderStyle" TargetType="Slider">  style definition ( I removed top one), I do not see any XAML parsing error.

Software Engineer
Aprimo, Inc

Please remember to mark the replies as answers if they answered your question

sladapter

Joined on 03-05-2008
Indiana, US
Posts 404