![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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#) |
| | #2 (permalink) |
| 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#) |
| |
| |
![]() |
| 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 |