Reputation: 3653
I want to pass a parameter from a User Control that uses a Custom Control, and use that on my Custom Control's cs. For example, if I had a Custom Control on a UserControl
In UserControl (e.g. ThisViewName.XAML):
<ctrl:PinWindowControl Tag="ThisViewName" Grid.Row="0"/>
Which pretty much just contains a button
Generic.xaml:
<Style TargetType="{x:Type local:PinWindowControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:PinWindowControl}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Button Width="100" Height="100"></Button>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
How can I get the Tag all the way to my PinWindowControl.cs file?
Upvotes: 1
Views: 49
Reputation: 10865
Assuming you created a DependencyProperty
in your PinWindowControl
:
You can access Tag
using this.Tag
. Your PinWindowControl
is a partial class
that is associated with your XAML
.
public class PinWindowControl.cs : FrameworkElement
{
public PinWindowControl()
{
Debug.WriteLine(this.Tag);
}
}
Upvotes: 1