I’m getting an error for this content template within a style: ‘Must specify both Property and Value for Setter.’ Aren’t I doing that?
<Style x:Key='LinkButton' TargetType='Button'> <Setter Property='Template'> <Setter.Value> <ControlTemplate TargetType='Button'> <ContentPresenter/> </ControlTemplate> </Setter.Value> </Setter> <Setter Property='ContentTemplate'> <Setter.Value> <DataTemplate> <Label x:Name='ContentRoot'> <StackPanel Orientation='Horizontal'> <Viewbox Width='24' Height='24' VerticalAlignment='Center'> <Image x:Name='ButtonImage' Source='{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=Tag}' /> </Viewbox> <TextBlock VerticalAlignment='Center' x:Name='ButtonText' Text='{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=Content}'></TextBlock> </StackPanel> </Label> <DataTemplate.Triggers> <Trigger Property='IsMouseOver' Value='True'> <Setter TargetName='ButtonText' Property='TextBlock.TextDecorations' Value='Underline'/> </Trigger> </DataTemplate.Triggers> </DataTemplate> </Setter.Value> </Setter>
And here is a button that will be using this style:
<Button Name='HelpButton' Style='{StaticResource LinkButton}' Height='30' Content='Help' Tag='Help.png'/>
Thanks!
I have loaded this up and have no such problems. The only problem I see is that your button will never have the style applied. This is because if you want the style applied you need to remove the x:Key from the style. Otherwise if you want the style applied only to the HelpButton, the definition should look like this:
But I cannot see the error you are seeing.