Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Control Template question

 
 
Old 01-10-2006   #1 (permalink)
Griff


 
 

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


 
 

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)
viliescu


 
 

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
 

Thread Tools



Vista Forums 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 Ltd

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