Noesis cannot set property of converter from resource
Posted: 18 Jun 2020, 21:55
EDIT: See post #3 for a more accurate description of the problem. It has nothing to do with resource dictionaries.
---------
I have a converter which has some properties. In a resource dictionary, I attempt to set some of these properties during the setup of the converter. This fails with a:
"[NOESIS/E] ResourceDictionary.xaml(6): StaticResource 'SomeColor' not found." error.
I've created a minimal example below. The extra Brushes.SomeBrush item in the resource dictionary is just to illustrate that the thing I'm trying to reference (StaticResource SomeColor) is indeed properly initialized and functioning. I only get the error when trying to apply it to the converter's property. This works in WPF.
Resource Dictionary:
Converter:
MainWindow:
---------
I have a converter which has some properties. In a resource dictionary, I attempt to set some of these properties during the setup of the converter. This fails with a:
"[NOESIS/E] ResourceDictionary.xaml(6): StaticResource 'SomeColor' not found." error.
I've created a minimal example below. The extra Brushes.SomeBrush item in the resource dictionary is just to illustrate that the thing I'm trying to reference (StaticResource SomeColor) is indeed properly initialized and functioning. I only get the error when trying to apply it to the converter's property. This works in WPF.
Resource Dictionary:
Code: Select all
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Tests">
<Color x:Key="SomeColor">#ff00ff00</Color>
<SolidColorBrush x:Key="Brushes.SomeBrush" Color="{StaticResource SomeColor}"/>
<local:ReturnColorConverter x:Key="Converters.ReturnColorConverter" SomeColorProperty="{StaticResource SomeColor}"/>
</ResourceDictionary>
Code: Select all
class ReturnColorConverter : IValueConverter
{
public Color SomeColorProperty { get; set; } = Colors.Red;
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return SomeColorProperty;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
Code: Select all
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Rectangle>
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Converter={StaticResource Converters.ReturnColorConverter}}"/>
</Rectangle.Fill>
</Rectangle>
</Grid>