Is it possible to send parameters to a control defined in a XAML?
For example if I have this XAML:
<UserControl x:Class="Controls.MyControl"
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">
<UserControl.Resources>
<ResourceDictionary Source="..\Colors.xaml" />
</UserControl.Resources>
<Grid>
<Polygon x:Name="plgPoly" Points="0,0 100,0 100,100 0,0" />
</Grid>
</UserControl>
But when I construct my “Polygon” I want to give it coordinates which depend on the control which contain it (like : this.Height, this.Width, etc…) or on other controls defined in the parent control.
Is it possible? how?
If the property that should reference another is a dependency property that can easily be done via a
Binding(withRelativeSource), otherwise you may need to construct your ownMarkupExtensionthat fetches the value once (rather than binding it).