Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

Closed Unassigned: Doesn't singularize the word 'searches' properly [323]

$
0
0
The convention to bind the SelectedItem property of a ListBox to a property that is a singular version of the Items collection doesn't handle the word 'searches' properly.

For example a ListBox bound to RecentSearches will not bind it's SelectedItem property to SelectedRecentSearch.

I'm using the following modified code for ConventionManager.Singularize which handle this:

``` C#
ConventionManager.Singularize = original =>
{
if (original.EndsWith("ies"))
{
return original.TrimEnd('s').TrimEnd('e').TrimEnd('i') + "y";
}
else if (original.EndsWith("es"))
{
return original.TrimEnd('s').TrimEnd('e');
}
else
{
return original.TrimEnd('s');
}
};
```

Since binding to something like Searches in an app must come up maybe this is worth correcting?
Comments: Singularize is more complex than thought. Leave it to CM users to override.

Viewing all articles
Browse latest Browse all 1760

Trending Articles