I am new to WPF and am not able to figure out how to change the property of the child ContentControl
of the Button
control on mouse over. My code looks something like this:
<Button x:Name="btnAddItem" Height="25" Width="25" Margin="5,0,0,0"
Style="{DynamicResource btnStyle}" ToolTip="Add Item">
<ContentControl Content="ContentControl" Height="20" Width="20"
Template="{DynamicResource contentTemplate}" />
</Button>
Now, when in the MouseOver
event of the Button
, I would like to change the size of the Button
as well as the size of the child ContentControl
. The ContentControl
actually contains a vector image for the Button
. Please help.
Your
Button
will automatically stretch to fit the size of it's contents, so get rid of it'sHeight
andWidth
properties. If you want to maintain the space between the edge of the Button and the ContentControl, use the ContentControl'sMargin
property.Then, use a
DataTrigger
in your ContentControl'sStyle
to change theHeight
/Width
when the mouse is over it. Be sure you setHeight
/Width
in your style instead of in your<ContentControl>
tag, because if you set it in the tag it will take precedence over the triggered value so will never change.