I need to create a custom property meaning rather using
<Style x:Key="ABC" TargetType="Rectangle">
<Setter Property="Fill" Value="Red"/>
</Style>
I like to have something like Rectangle and assign it an ID so later when it is dropped on Canvas I can retrieve its ID.
<Style x:Key="ABC" TargetType="Rectangle">
<Setter Property="Fill" Value="Red"/>
**<Setter Property="ID" Value="1234567890-ABC"/>**
</Style>
How can I define that custom property?
Regards,
Amit
Define a custom attached property in a separate class:
Then you can use this:
localmust be defined in the root element of your XAML appromimately like this:where
AttPropTestis the namespace of the assembly.In code, you can determine the ID with
Prop.GetID(myRect).