Windows Vista Forums
Vista Forums Home Join Vista Forums Donate 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

Supplying named content as a parameter to control template.

Closed Thread
 
Thread Tools Display Modes
Old 01-31-2006   #1 (permalink)
Griff
Guest


 

Supplying named content as a parameter to control template.

I'd like in my main markup to specify a control template by name as one of my
parameters.
That is to say, my App resources will have a load of different vector
graphics pictures and I want to choose one as a parameter to use on my
control when I add a control to my markup.

So in the markup I call my button class that inherits from Button.

<local:myButton x:Name="button1"
Content="{StaticResource myPicture1}"
Style="{StaticResource myButtonStyle}" />

and in the applications resources I have

<Style x:Key="myButtonStyle" TargetType="{x:Type local:myButton}">
<Setter Property="Template" Value="{StaticResource myButtonTemplate}" />
</Style>

<ControlTemplate x:Key="myButtonTemplate" TargetType="{x:Type
local:myButton}">
<Grid>
<ContentPresenter Grid.Row="0" Content="{TemplateBinding
Property=Content}"/>
</Grid>
</ControlTemplate>


<ControlTemplate x:Key="myPicture1">
some graphical elements
</ControlTemplate>

<ControlTemplate x:Key="myPicture2">
completely different set of graphical elements
</ControlTemplate>

etc


As I've written it does not work.
I'm not sure if I'm just missing some syntax or if the approach is
fundamentally doomed. I'd really prefer not to have to do this in code.


--
Griff
(trying to make an industrial UI with XAML/WPF/c#)
Old 01-31-2006   #2 (permalink)
Griff
Guest


 

RE: Supplying named content as a parameter to control template.

Have found out how to do this.

I supply the content in the main markup with

<local:myControl
param1="{StaticResource myPicture1}"
Style ="{StaticResource myStyle }" />

Then in the Control Temnplate called up by the Style I dusplay the content
with

<Control Template="{TemplateBinding Property=param1}"/>

Which seems obvious with hindsight...


--
Griff
(trying to make an industrial UI with XAML/WPF/c#)


"Griff" wrote:

> I'd like in my main markup to specify a control template by name as one of my
> parameters.
> That is to say, my App resources will have a load of different vector
> graphics pictures and I want to choose one as a parameter to use on my
> control when I add a control to my markup.
>
> So in the markup I call my button class that inherits from Button.
>
> <local:myButton x:Name="button1"
> Content="{StaticResource myPicture1}"
> Style="{StaticResource myButtonStyle}" />
>
> and in the applications resources I have
>
> <Style x:Key="myButtonStyle" TargetType="{x:Type local:myButton}">
> <Setter Property="Template" Value="{StaticResource myButtonTemplate}" />
> </Style>
>
> <ControlTemplate x:Key="myButtonTemplate" TargetType="{x:Type
> local:myButton}">
> <Grid>
> <ContentPresenter Grid.Row="0" Content="{TemplateBinding
> Property=Content}"/>
> </Grid>
> </ControlTemplate>
>
>
> <ControlTemplate x:Key="myPicture1">
> some graphical elements
> </ControlTemplate>
>
> <ControlTemplate x:Key="myPicture2">
> completely different set of graphical elements
> </ControlTemplate>
>
> etc
>
>
> As I've written it does not work.
> I'm not sure if I'm just missing some syntax or if the approach is
> fundamentally doomed. I'd really prefer not to have to do this in code.
>
>
> --
> Griff
> (trying to make an industrial UI with XAML/WPF/c#)

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
TFS 2008 Process Template: Default value tag for work item fieldsdoes not allow more than 255 characters to be entered into an HTML control Steve .NET General 0 07-23-2008 11:13 AM
How to best control parameter attributes and parameter parsing in your own scripts? Audun Gjerken PowerShell 1 03-04-2007 04:07 PM
Presenting rich content in a control template Griff Avalon 2 01-31-2006 06:59 AM
Control Template question Griff Avalon 3 01-10-2006 03:54 PM
VS/WPF crash on trying to add a WinFX Custom Control template to Jason Dolinger Avalon 5 01-10-2006 03:52 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