I'm looking for a way to essentially give an item in a ResourceDictionary multiple keys. Is there a way to do this?
<DataTemplate x:Key="myTemplate" ... />
<AliasedResource x:Key="myTemplateViaAlias" Target="myTemplate" OR_Target={StaticResource myTemplate} />
When I call TryFindResource("myTemplateViaAlias") I want to get myTemplate out. I suppose I could create an AliasedResource class myself and dereference it in code when I get it out of the dictionary, but I'd rather not do that if there's a built-in way.
You can pipe resources through dynamic resources (note that crappy UI designers won't like it)
<Color x:Key="color">Red</Color>
<DynamicResource x:Key="mycolor" ResourceKey="color"/>
<Rectangle Width="100" Height="100">
<Rectangle.Fill>
<SolidColorBrush Color="{StaticResource color}"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle Width="100" Height="100">
<Rectangle.Fill>
<SolidColorBrush Color="{StaticResource mycolor}"/>
</Rectangle.Fill>
</Rectangle>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With