Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Store Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems.

Go Back   Vista Forums > Vista technology newsgroups > Avalon

Why is this so difficult (Template question)

Reply
 
Thread Tools Display Modes
Old 01-19-2008   #1 (permalink)
russell.smallwood
Guest
 
Posts: n/a

Why is this so difficult (Template question)

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
  Reply With Quote

Reply

Thread Tools
Display Modes









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