I'm learning about binding in WPF. I'm having a lot of trouble debugging the parse errors in my xaml, though. What's wrong with this little piece? :
<Border Name="TrackBackground"
Margin="0"
CornerRadius="2"
Grid.Row="1"
Grid.Column="1"
Background="BlanchedAlmond"
BorderThickness="1"
Height="{TemplateBinding Height}">
<Canvas Name="PART_Track" Background="DarkSalmon" Grid.Row="1" Grid.Column="1">
<Thumb Name="ThumbKnob" Height="{Binding ElementName=Part_Track, Path=Height, Mode=OneWay}" />
</Canvas>
</Border>
It's the databinding that breaks. I get an InvalidAttributeValue
exception for ThumbKnob.Height when I try to run this.
Changing the ElementName didn't help. There must me something else I'm not getting.
I should mention that I'm testing this in Silverlight. The exact message I'm getting out of Internet Explorer is:
XamlParseException: Invalid attribute value for property Height.
This whole thing is inside a ControlTemplate. I'm making a slider control just to teach myself the concepts.
The ElementName property on a Binding is not supported in Silverlight.
You will notice, if you go into the code behind or inspect the Binding object in class explorer, it doesn't have a property named ElementName.