lbugnion / mvvmlight

The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Windows 10 UWP, Windows Presentation Foundation (WPF), Silverlight, Windows Phone.
http://www.mvvmlight.net
MIT License
1.16k stars 311 forks source link

Proposal: Include essential, but missing, WPF/XAML functionality #4

Open daiplusplus opened 6 years ago

daiplusplus commented 6 years ago

I have my own little WPF utility library that provides some essential functionality that isn't included in WPF-proper (or other XAML frameworks, I assume) or MvvmLight. I'll be happy to share my implementation if you like. I think if they were included in the MvvmLight.Extras then they'd benefit more people.

I also have plans to build a Markup-Extension or Binding Converter that allows for C#-like expressions to be used in bindings, to eliminate the need for most Converters or hacks in ViewModels. Already there's the MathConverter available here: https://rachel53461.wordpress.com/2011/08/20/the-math-converter/ - but that's restricted to numeric arithmetic - but my proposal would use something like DLR/Dynamic-Linq or the built-in C# expression parser so we could do something like this:

I'm also looking at possibly avoiding common converters in Binding expressions by using better-typed Attached Properties, e.g.:

<Label mvvm:Vis.Visible="{Binding SomeBooleanProperty}"  />`

...where Vis.Visible is a Boolean property that proxies UIElement.Visibility, instead of:

<Resources>
    <BooleanToVisibilityConverter x:Key="boolToVis" />
</Resources>

<Label Visibility="{Binding SomeBooleanProperty, Converter={StaticResource boolToVis}}" />
lbugnion commented 6 years ago

Interesting propositions and thanks so much for sharing the ideas. I am quite conservative in adding new features but I took notes of these ideas.