Reputation: 1626
I'm trying to set the FontSize -- amoung other things -- on some control's within a UserControl to the UserControl-level FontSize. This is not working:
<UserControl x:Class="TestWpfApplication1.Scratch.UserControlFontSizeProp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock
FontSize="{Binding RelativeSource={RelativeSource self},Path=FontSize}">
Text
</TextBlock>
</Grid>
</UserControl>
What am I doing wrong? Thanks.
Upvotes: 3
Views: 3949
Reputation: 97
I use
FontSize="{Binding Parent.Parent.FontSize, RelativeSource={RelativeSource Self}}"
Upvotes: 0
Reputation: 332
Think this should work..
<TextBlock FontSize="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=FontSize}" />
Upvotes: 7