View Issue Details

IDProjectCategoryView StatusLast Update
0000773NoesisGUIUnitypublic2018-11-22 23:24
ReporterScherub Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status assignedResolutionopen 
Summary0000773: DynamicResourceExtension and IProvideValueTarget missing
Description

I'm trying to do something like this: http://stackoverflow.com/questions/33816511/how-do-you-create-a-dynamicresourcebinding-that-supports-converters-stringforma

But there are several missing classes in NoesisGUI such as DynamicResourceExtension or IProvideValueTarget.

My goal is to return a dynamic resource using a IValueConverter to convert my input 'Medal' into an 'image' of my image sheet.

Now that there are DataTriggers supported I'm wondering whether I should use these for now as a workaround. The problem with this approach is that I have to define it in several templates. Do you have a better idea? :)

PlatformAny

Activities

sfernandez

sfernandez

2015-11-26 14:08

manager   ~0003294

Last edited: 2015-11-26 14:08

Would it be a possibility to load the 'image' resources in a global class that can be accessed from the converter?

Something like this:


public static class ImageResources
{
ResourceDictionary _resources;

public static ImageBrush Find(string key)
{
if (_resources == null)
{
_resources = NoesisGUISystem.LoadXaml("Assets/Images/ImageResources.xaml");
}
return _resources[key] as ImageBrush;
}
}

And the converter:


public class IdImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ImageResources.Find(((ImageId)value).ToString());
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

Scherub

Scherub

2015-11-27 11:41

reporter   ~0003302

Well, it's not the solution I had in mind but at least it works. Thanks! :)

Issue History

Date Modified Username Field Change
2015-11-26 02:54 Scherub New Issue
2015-11-26 14:08 sfernandez Note Added: 0003294
2015-11-26 14:08 sfernandez Assigned To => sfernandez
2015-11-26 14:08 sfernandez Status new => feedback
2015-11-26 14:08 sfernandez Note Edited: 0003294
2015-11-27 11:41 Scherub Note Added: 0003302
2015-11-27 11:41 Scherub Status feedback => assigned
2018-11-01 02:14 jsantos View Status public => private
2018-11-22 23:24 sfernandez View Status private => public
2018-11-22 23:24 sfernandez Platform => Any
2025-10-10 13:29 jsantos Category Unity3D => Unity