Page 1 of 1

Slash in ResourceDictionary Key not recognized

Posted: 14 May 2018, 11:09
by horeaper
Giving one ResourceDictionary:
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <sys:String x:Key="LoginScreen/Guest">Guest</sys:String>
    <sys:String x:Key="LoginScreen/Register">Register</sys:String>
    <sys:String x:Key="LoginScreen/Login">Login</sys:String>
(...and the list goes on and on...)
Create and apply a simple view model:
public class ViewModel
{
    public ResourceDictionary Resources { get; } = LoadResourceDictionary();
}
(...inside some UserControl...)
DataContext = new ViewModel();
And use it like this:
<Button Content="{Binding Resources[LoginScreen/Login]}" Width="80" Height="25" />
It works fine under WPF, but Noesis (2.1.0f1 with Unity) shows:
NoesisException: Assets/Xaml/LoginWindow.xaml(65): Unable to convert 'Resources[LoginScreen/Login]' to a valid value for property Binding.
Rethrow as NoesisException
(wrapper dynamic-method) System.Object:lambda_method(System.Runtime.CompilerServices.Closure)
Rethrow as NoesisException
Rethrow as NoesisException
(wrapper dynamic-method) System.Object:lambda_method(System.Runtime.CompilerServices.Closure)
Rethrow as NoesisException
Seems Noesis doesn't understand the slash character. Changing it to underscore:
<sys:String x:Key="LoginScreen_Login">Login</sys:String>
(...)
<Button Content="{Binding Resources[LoginScreen_Login]}" Width="80" Height="25" /
Now it works.

But we have tens of thousands definitions using slash inside x:Key, do I have to change ALL of them?? Not to mention it's gonna cause conflicts since we also uses underscore.

Re: Slash in ResourceDictionary Key not recognized

Posted: 16 May 2018, 22:45
by sfernandez
Hi, I can confirm it is a bug in our PropertyPath parser.
It will be fixed for the next release.