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

Control Template question

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


 

Control Template question

I have a Control Template that defines how a control element (ie a button)
will look.
Is it possible to specify a text related property in the ControlTemplate so
that IF the button's content contains any text, it will be displayed with
this property ?

An alternative would be to always use a custom "buttoncontent" object for
the button's content and use a DataTemplate to define how to display
buttoncontent, but this makes the Xaml markup pretty disjointed.



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

My System SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
viliescu
Guest


 

RE: Control Template question

I don't think I understand what are you trying to do. Can you elaborate a
little bit?
--
Valentin Iliescu [MVP C#]


"Griff" wrote:

> I have a Control Template that defines how a control element (ie a button)
> will look.
> Is it possible to specify a text related property in the ControlTemplate so
> that IF the button's content contains any text, it will be displayed with
> this property ?
>
> An alternative would be to always use a custom "buttoncontent" object for
> the button's content and use a DataTemplate to define how to display
> buttoncontent, but this makes the Xaml markup pretty disjointed.
>
>
>
> --
> Griff
> (trying to make an industrial UI with XAML/WPF/c#)

My System SpecsSystem Spec
Old 01-10-2006   #3 (permalink)
Griff
Guest


 

RE: Control Template question

Sorry, I'll try to be a bit clearer.

I have used a ControlTemplate successfully to customise a button (shape,
fill, shadow etc) but I still have 2 problems.

1. I want to display all button text as white foreground, transparent
background.
So I'd like to write in my control template

<Textblock Text="{TemplateBinding Property=Text}"/>
Except that the Button does not have a "text" parameter - it has "content".
Can I somehow specify "if the content of this button happens to be text make
it white foreground" ?

2. I'd in fact like to break up the appearance within the button with a
grid but have just found that I cannot (apparently) have RowDefinitions
within the ControTemplate tag, which has somewhat caught me out.


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


"viliescu" wrote:

> I don't think I understand what are you trying to do. Can you elaborate a
> little bit?
> --
> Valentin Iliescu [MVP C#]
>
>
> "Griff" wrote:
>
> > I have a Control Template that defines how a control element (ie a button)
> > will look.
> > Is it possible to specify a text related property in the ControlTemplate so
> > that IF the button's content contains any text, it will be displayed with
> > this property ?
> >
> > An alternative would be to always use a custom "buttoncontent" object for
> > the button's content and use a DataTemplate to define how to display
> > buttoncontent, but this makes the Xaml markup pretty disjointed.
> >
> >
> >
> > --
> > Griff
> > (trying to make an industrial UI with XAML/WPF/c#)

My System SpecsSystem Spec
Old 01-10-2006   #4 (permalink)
viliescu
Guest


 

RE: Control Template question

Much clearer

1. Add a Setter in the template style to make the Foreground White
It will look like

<Style x:Key="MyButton" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
...

2. For me it works. This is a snippet of the template's style (notice there
is
no Row/ColumnDefinitions tag)

<Style x:Key="MyButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid>
<ColumnDefinition Width="4"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="4"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
...
--
Valentin Iliescu [MVP C#]


"Griff" wrote:

> Sorry, I'll try to be a bit clearer.
>
> I have used a ControlTemplate successfully to customise a button (shape,
> fill, shadow etc) but I still have 2 problems.
>
> 1. I want to display all button text as white foreground, transparent
> background.
> So I'd like to write in my control template
>
> <Textblock Text="{TemplateBinding Property=Text}"/>
> Except that the Button does not have a "text" parameter - it has "content".
> Can I somehow specify "if the content of this button happens to be text make
> it white foreground" ?
>
> 2. I'd in fact like to break up the appearance within the button with a
> grid but have just found that I cannot (apparently) have RowDefinitions
> within the ControTemplate tag, which has somewhat caught me out.
>
>
> --
> Griff
> (trying to make an industrial UI with XAML/WPF/c#)
>
>
> "viliescu" wrote:
>
> > I don't think I understand what are you trying to do. Can you elaborate a
> > little bit?
> > --
> > Valentin Iliescu [MVP C#]
> >
> >
> > "Griff" wrote:
> >
> > > I have a Control Template that defines how a control element (ie a button)
> > > will look.
> > > Is it possible to specify a text related property in the ControlTemplate so
> > > that IF the button's content contains any text, it will be displayed with
> > > this property ?
> > >
> > > An alternative would be to always use a custom "buttoncontent" object for
> > > the button's content and use a DataTemplate to define how to display
> > > buttoncontent, but this makes the Xaml markup pretty disjointed.
> > >
> > >
> > >
> > > --
> > > Griff
> > > (trying to make an industrial UI with XAML/WPF/c#)

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is this so difficult (Template question) russell.smallwood Avalon 0 01-19-2008 09:31 PM
Tooltip Template Question Michael Jackson Avalon 1 05-26-2007 09:18 PM
Supplying named content as a parameter to control template. Griff Avalon 1 01-31-2006 06:59 AM
Presenting rich content in a control template Griff Avalon 2 01-31-2006 06:59 AM
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 51