| Subject: Why is this so difficult (Template question) |
| Group: microsoft.public.windows.developer.winfx.avalon |
| Date: 1/19/2008 8:31:12 PM |
| From: russell.smallwood@gmail.com |
Hello all, I'm trying to do something that I thought would be simple with wpf. Basically, I want to create a template that sticks a TextBlock on the end of a ComboBox. The idea is that when my forms are in "edit" mode that the required fields are marked with a red asterisk. While I've figured out how to do this with a textbox: <Style x:Key="RequiredEditableTextBox" TargetType="{x:Type TextBox}"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate x:Key="RequiredEditableTextBoxTemplate" TargetType="{x:Type TextBox}"> <StackPanel Orientation="Horizontal"> <TextBox Text="{TemplateBinding Text}"/> <TextBlock Style="{StaticResource RequiredFieldGlyph}"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> I'm mystified as to how one would accomplish this with a more complex control like a combobox. What I really want is a template that refers to the parent control, essentially saying "Draw yourself here" <Style x:Key="RequiredEditableComboBox" TargetType="{x:Type ComboBox}"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate x:Key="RequiredEditableComboBoxTemplate" TargetType="{x:Type ComboBox}"> <StackPanel Orientation="Horizontal"> ---I WANT TO DRAW THE ORIGNIAL COMBOBOX HERE -- <TextBlock Style="{StaticResource RequiredFieldGlyph}"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> But I can figure out how. The difficulty I'm having leads me to believe that I may be thinking of the problem in the wrong context etc. Any ideas would be appreciated. Thanks -r |
| Back |