tags:

views:

16

answers:

2

Hello everyone

I'm trying to style an element in WPF which displays a yellow border around anything thats in it and shows a tool-tip when the cursor is over it. The problem is that I don't have much of an idea how to do this and anything I tried does not seem to work.

Here is what I have until now:

<Style x:Key="HistoryElementStyle"
       TargetType="{x:Type Control}">
    <Setter Property="BorderBrush"
            Value="Yellow"/>
    <Setter Property="BorderThickness"
            Value="1.5" />
    <Setter Property="CornerRadius"
            Value="2" />
    <Setter Property="ToolTip">
        <Setter.Value>
            <ToolTip Template="{StaticResource HistoryTooltipTemplate}" />
        </Setter.Value>
    </Setter>
    <Setter Property="Template">
        <Setter.Value>
            <ContentPresenter x:Name="PART_Content"
                              Width="Auto"
                              HorizontalAlignment="Stretch"
                              ContentSource="Content"
                              IsEnabled="{TemplateBinding IsEnabled}" />
        </Setter.Value>
    </Setter>
</Style>

Visual Studio complains that the ContentPresenter is an invalid type.

Cheers

AC

A: 

I'd try adding the DataTempalte tag around the ContentPresenter (sorry, I cannot test from where I am writing this).

Timores
Now DataTemplate is the invalid type. :(
Anonymous Coward
Sorry. Fortunately, @Mael had the solution.
Timores
+2  A: 

You must wrap the ContentPresenter around a <ControlTemplate TargetType="Control" /> to match the type of the Control.Template property.

Mael
That did the trick.
Anonymous Coward