OT: Xaml Binding, default value from Resources.Resx?

OT: Xaml Binding, default value from Resources.Resx?

Old forum URL: forums.lhotka.net/forums/t/6510.aspx


ajj3085 posted on Thursday, February 26, 2009

Hi,

I'm trying to setup some Wpf controls so that Title is databound, but it's default value is retreived from the Properties.Resources class.  The reason I want to do this is because I have the control load asyncronously, so until the DataChanged event fires I have nothing for the Title.  So I'd like a default value, which isn't hardcode but comes from the resx file.  I try to avoid hardcoding strings wherever possible.. so that I can share the same strings without digging through code.

Any ideas?

Thanks
Andy

Fintanv replied on Thursday, February 26, 2009

Can you bind to the resource string using the ResourceUri attribute?

Is there some reason that your bound business object couldn't provide the default value unless it has retrieved the 'real' value from your data source?  That way everything is nicely encapsulated.

ajj3085 replied on Thursday, February 26, 2009

Well the BO can't provide the value because it hasn't even been loaded yet at the point I want the Loading caption to be used.  Once it is loaded, I'll use the part number or whatever as part of the caption.. but  until then the tab has no caption.

I think if you set the Resources.resx to generate a public class, you can then use the x:Static in the binding and it will read the value.

Copyright (c) Marimer LLC