You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At work I have developed numerous control libraries utilizing Elmish.WPF for the consumption of other F# Elmish.WPF applications. Recently the need to use some of these controls in a C# WPF application has come up. I have managed to get it working, but I feel like there is something wrong with my implementation. Or, at least, that there is room for improvement either on my end or Elmish.WPF's.
However, there are a few issues with this implementation.
The user has to add additional code in order to initialize the control, instead of having it "just work" like C# based controls
Poor MVVM practice. UI-centric code is required instead of just passing parameters through XAML
I attempted one other approach in an attempt to mitigate the above issues. I added the initialization code after InitializeComponent in the control itself. This ended up not working because working with the F# libraries from C# is a less than ideal experience and results in a ton of boilerplate to get working (e.g. using FuncConvert instead of just passing in a System.Func). In addition, the passing of an additional parameter (in this case, SomeParam) to the init for the model was not doable without adding yet another project in the mix to avoid a circular dependency.
In addition, is there a best-approach for adding DependencyProperty's to an Elmish.WPF control? So far I've used a handful, but none that ended up needing to be used inside the control's logic itself. That is not to say it won't come up, however. It also forces the programmer to look in two different places for potential bindings.
Is there a better approach that I am missing? Or is this a limitation of trying to use Elmish.WPF-based controls from a non-F# application?
The text was updated successfully, but these errors were encountered:
Giving you a quick reply here to say that I will eventually take a detailed look at everything you have shared but I don't know right now when that will be.
I am not very interested at the moment in providing better/any support for C#. However, I am open to changes that improve the C# experience as long as it doesn't hurt the F# experience or introduce a maintenance burden.
In the meantime, maybe someone else will review your code and provide some feedback.
Hello,
At work I have developed numerous control libraries utilizing Elmish.WPF for the consumption of other F# Elmish.WPF applications. Recently the need to use some of these controls in a C# WPF application has come up. I have managed to get it working, but I feel like there is something wrong with my implementation. Or, at least, that there is room for improvement either on my end or Elmish.WPF's.
Currently, I am creating a function like the following in the Control logic: https://github.com/ChernayaKoshka/Minimal3rdPartyControl/blob/main/Minimal.Controls/Controls.fs#L35-L37
And then calling it on the C# side: https://github.com/ChernayaKoshka/Minimal3rdPartyControl/blob/main/Minimal/MainWindow.xaml.cs#L12
However, there are a few issues with this implementation.
I attempted one other approach in an attempt to mitigate the above issues. I added the initialization code after
InitializeComponent
in the control itself. This ended up not working because working with the F# libraries from C# is a less than ideal experience and results in a ton of boilerplate to get working (e.g. usingFuncConvert
instead of just passing in aSystem.Func
). In addition, the passing of an additional parameter (in this case,SomeParam
) to theinit
for the model was not doable without adding yet another project in the mix to avoid a circular dependency.In addition, is there a best-approach for adding
DependencyProperty
's to an Elmish.WPF control? So far I've used a handful, but none that ended up needing to be used inside the control's logic itself. That is not to say it won't come up, however. It also forces the programmer to look in two different places for potential bindings.Is there a better approach that I am missing? Or is this a limitation of trying to use Elmish.WPF-based controls from a non-F# application?
The text was updated successfully, but these errors were encountered: