Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Using a StaticResource in a template

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Keith Patrick
Guest


 

Using a StaticResource in a template

I've got a style declared where, within the Template setter, I try to drop
in a previously-declared resource declared like so:
<Polyline x:Key="UpArrowGlyph" Points="0,0 0.5,0.3 1,0" Stroke="#FF5B6473"
StrokeThickness="0.2" RenderTransformOrigin="0.5,0.5">

<Polyline.RenderTransform>

<RotateTransform Angle="180"/>

</Polyline.RenderTransform>

</Polyline>



However, I can't seem to get the syntax for dropping it into a style. I use
them in my UI itself, and it works just fine, but if I construct my template
in this way:

<Viewbox Stretch="Fill">

<StaticResource ResourceKey="UpArrowGlyph" />

</Viewbox>

It says I can't use non-frameworkelements in my style. I know I'm missing
some basic piece of syntax, but I've been stumped on this one for several
days (including getting sidetracked on a 360 ).



My System SpecsSystem Spec
Old 02-02-2006   #2 (permalink)
Nick Kramer [MSFT]
Guest


 

Re: Using a StaticResource in a template

> It says I can't use non-frameworkelements in my style.

I don't think it has anything to do with the resource reference, it's
because Polyline is not a subclass of FrameworkElement. The root element in
the template must be a framework element, if you don't have a useful
framework element just use a Border with zero-sized border.

-Nick Kramer [MSFT]
http://blogs.msdn.com/nickkramer

---
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Keith Patrick" <richard_keith_patrick@nospam.hotmail.com> wrote in message
news:uI1ziVfJGHA.3100@tk2msftngp13.phx.gbl...
> I've got a style declared where, within the Template setter, I try to drop
> in a previously-declared resource declared like so:
> <Polyline x:Key="UpArrowGlyph" Points="0,0 0.5,0.3 1,0" Stroke="#FF5B6473"
> StrokeThickness="0.2" RenderTransformOrigin="0.5,0.5">
>
> <Polyline.RenderTransform>
>
> <RotateTransform Angle="180"/>
>
> </Polyline.RenderTransform>
>
> </Polyline>
>
>
>
> However, I can't seem to get the syntax for dropping it into a style. I
> use them in my UI itself, and it works just fine, but if I construct my
> template in this way:
>
> <Viewbox Stretch="Fill">
>
> <StaticResource ResourceKey="UpArrowGlyph" />
>
> </Viewbox>
>
> It says I can't use non-frameworkelements in my style. I know I'm missing
> some basic piece of syntax, but I've been stumped on this one for several
> days (including getting sidetracked on a 360 ).
>



My System SpecsSystem Spec
Old 02-04-2006   #3 (permalink)
Nick Kramer [MSFT]
Guest


 

Re: Using a StaticResource in a template

D'oh! It was pointed out to me that PolyLine is a Shape and thus a
FrameworkElement.

What's the complete xaml you're using?

--
-Nick Kramer [MSFT]
http://blogs.msdn.com/nickkramer

---
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Nick Kramer [MSFT]" <nkramer@ms.spam> wrote in message
news:eWC9M25JGHA.216@TK2MSFTNGP15.phx.gbl...
>> It says I can't use non-frameworkelements in my style.

>
> I don't think it has anything to do with the resource reference, it's
> because Polyline is not a subclass of FrameworkElement. The root element
> in the template must be a framework element, if you don't have a useful
> framework element just use a Border with zero-sized border.
>
> -Nick Kramer [MSFT]
> http://blogs.msdn.com/nickkramer
>
> ---
> This posting is provided "AS IS" with no warranties, and confers no
> rights. Use of included script samples are subject to the terms specified
> at http://www.microsoft.com/info/cpyright.htm
>
>
> "Keith Patrick" <richard_keith_patrick@nospam.hotmail.com> wrote in
> message news:uI1ziVfJGHA.3100@tk2msftngp13.phx.gbl...
>> I've got a style declared where, within the Template setter, I try to
>> drop in a previously-declared resource declared like so:
>> <Polyline x:Key="UpArrowGlyph" Points="0,0 0.5,0.3 1,0"
>> Stroke="#FF5B6473" StrokeThickness="0.2" RenderTransformOrigin="0.5,0.5">
>>
>> <Polyline.RenderTransform>
>>
>> <RotateTransform Angle="180"/>
>>
>> </Polyline.RenderTransform>
>>
>> </Polyline>
>>
>>
>>
>> However, I can't seem to get the syntax for dropping it into a style. I
>> use them in my UI itself, and it works just fine, but if I construct my
>> template in this way:
>>
>> <Viewbox Stretch="Fill">
>>
>> <StaticResource ResourceKey="UpArrowGlyph" />
>>
>> </Viewbox>
>>
>> It says I can't use non-frameworkelements in my style. I know I'm
>> missing some basic piece of syntax, but I've been stumped on this one for
>> several days (including getting sidetracked on a 360 ).
>>

>
>



My System SpecsSystem Spec
Old 02-13-2006   #4 (permalink)
Keith Patrick
Guest


 

Re: Using a StaticResource in a template

This is the style:
<Style x:Key="{x:Type ScrollBar}"
TargetType="{x:Type ScrollBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid Background="{TemplateBinding Background}">
<RowDefinition MaxHeight="{DynamicResource {x:Static
SystemParameters.VerticalScrollBarButtonHeightKey}}" />
<RowDefinition Height="1E-05*" />
<RowDefinition MaxHeight="{DynamicResource {x:Static
SystemParameters.VerticalScrollBarButtonHeightKey}}" />
<RepeatButton Command="ScrollBar.LineUpCommand"
Height="{DynamicResource {x:Static
SystemParameters.VerticalScrollBarButtonHeightKey}}"
MinWidth="{DynamicResource {x:Static
SystemParameters.VerticalScrollBarWidthKey}}">
<Viewbox Stretch="Fill">
<StaticResource ResourceKey="UpArrowGlyph"
/>
</Viewbox>
</RepeatButton>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

And teh resource is here:
<Polyline x:Key="UpArrowGlyph"
Points="0,0 0.5,0.3 1,0"
Stroke="#FF5B6473"
StrokeThickness="0.2"
RenderTransformOrigin="0.5,0.5">
<Polyline.RenderTransform>
<RotateTransform Angle="180"/>
</Polyline.RenderTransform>
</Polyline>




My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Folder Template Yondaime Vista file management 7 12-19-2007 11:28 AM
template with Netsh James Vista networking & sharing 6 05-15-2007 10:17 PM
Vista adm template for AD? Scott Townsend Vista account administration 0 02-14-2007 09:43 AM
StaticResource markup extension with Binding HolaMan Avalon 0 07-25-2006 12:40 PM
NavigationWindow Template Stephen Planck Avalon 1 01-10-2006 03:53 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51