Hi
I'm often unsure where the best place is to format my properties for the UI in my BO. For example I have the following:
private static readonly PropertyInfo<bool> IsActiveProperty = RegisterProperty<bool>(o => o.IsActive);
private bool _IsActive = IsActiveProperty.DefaultValue;
public string IsActive
{
get
{
var value = GetProperty(IsActiveProperty, _IsActive);
return value ? Resources.Yes : Resources.No;
}
}
Basically my question is - is this best practice? The good thing is I can use the _IsActive bool internally if I need to. An alternative is to convert in the data access method but that doesn't seem like best practice to me.
Any thoughts or suggestions appreciated.
Thanks
Andrew
What about the way the samples handle conversion of SmartDate<->String:
private static PropertyInfo<SmartDate> StartedProperty = RegisterProperty<SmartDate>(p=>p.Started);
public string Started
{
get { return GetPropertyConvert<SmartDate, string>(StartedProperty); }
set { SetPropertyConvert<SmartDate, string>(StartedProperty, value); }
}
Not sure from the top of my head but I am sure you can make a small tweak to convert from String<-->Bool, that would be a lot cleaner...
Hi,
Just be aware that you may also need to add a TypeConverter and modify Utilities.CoeceValue method to handle conversion and set the Value property of a SmartBoolean if you choose to go down that path.
Is there any particular reason you're exposing a boolean as a string? Normally I'd expect you'd bind to a checkbox or similar control. If you need to allow editing as a string though, as triplea said you'd want something like a SmartBoolean.
Copyright (c) Marimer LLC