![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 | 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 Specs![]() |
| | #2 (permalink) |
| 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 Specs![]() |
| | #3 (permalink) |
| 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 Specs![]() |
| | #4 (permalink) |
| 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 Specs![]() |
![]() |
| 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 |