![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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![]() |