locked
Why is this so difficult (Template question) - Cross post (russell.smallwood@gmail.com) - 1/19/2008 7:39 PM PST RRS feed

  • Question

  • By: russell.smallwood@gmail.com


    (Cross-posted in Microsoft....WinFX.Avalon)

    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
    Friday, February 22, 2008 4:24 PM