In a ResourceDictionary file I want to alias the resource NavyBlueBrush
as TopBrush
to give the resource a logical meaning.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:globalResources="clr-namespace:GlobalResources">
<SolidColorBrush x:Key="NavyBlueBrush" Color="#01354b"/>
...
<StaticResourceExtension ResourceKey="NavyBlueBrush" x:Key="TopBrush"/>
...
</ResourceDictionary>
In the application I can use NavyBlueBrush
just fine. But if I try to use TopBrush
, it is not applied. What's wrong?
<Grid Background="{Binding Mode=OneWay, Source={StaticResource NavyBlueBrush}}"> --- Grid is colored
...
<Grid Background="{Binding Mode=OneWay, Source={StaticResourceExtension TopBrush}}" /> --- Grid IS NOT colored