Open solatticus opened 6 years ago
Did you put your ViewModel in a separate DLL? It's possible it hasn't been loaded when Forms goes looking for it.
It’s all in the same project.
Sent from ProtonMail Mobile
On Fri, Mar 30, 2018 at 4:00 PM, Frank A. Krueger notifications@github.com wrote:
Did you put your ViewModel in a separate DLL? It's possible it hasn't been loaded when Forms goes looking for it.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/praeclarum/Ooui","title":"praeclarum/Ooui","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/praeclarum/Ooui"}},"updates":{"snippets":[{"icon":"PERSON","message":"@praeclarum in #123: Did you put your ViewModel in a separate DLL? It's possible it hasn't been loaded when Forms goes looking for it."}],"action":{"name":"View Issue","url":"https://github.com/praeclarum/Ooui/issues/123#issuecomment-377609375"}}}
OK, cool. Can you also paste in some of the XAML where you declare the namespace and create the binding? I've never done the binding in XAML.
It’s in the link I posted, but I can copy it over when I get home.
Thanks for this!
Sent from ProtonMail Mobile
On Fri, Mar 30, 2018 at 4:05 PM, Frank A. Krueger notifications@github.com wrote:
OK, cool. Can you also paste in some of the XAML where you declare the namespace and create the binding? I've never done the binding in XAML.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/praeclarum/Ooui","title":"praeclarum/Ooui","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/praeclarum/Ooui"}},"updates":{"snippets":[{"icon":"PERSON","message":"@praeclarum in #123: OK, cool. Can you also paste in some of the XAML where you declare the namespace and create the binding? I've never done the binding in XAML."}],"action":{"name":"View Issue","url":"https://github.com/praeclarum/Ooui/issues/123#issuecomment-377610572"}}}
Sorry, missed the link, it's perfect.
In my case (WASM + Xamarin Forms) MVVM works as expected (Button.Command, Button.Text). Example here: https://github.com/zbigniew-gajewski/ooui-wasm-aspnet-core-xaml
Does declaring & binding the ViewModel via XAML work?
Yes! (at least Button.Command, Button.Text). Here is working example (based on Ooui.Wasm) with declarative binding XAML / ViewModel: https://github.com/zbigniew-gajewski/ooui-wasm-aspnet-core-xaml
I have also had success binding to the viewmodel directly from XAML:
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:infrastructureMVVMFrameworkConverters="clr-namespace:OouiWXF.Infrastructure.MVVMFramework.Converters" xmlns:local="clr-namespace:OouiWXF" xmlns:viewModel="clr-namespace:OouiWXF.ViewModels.MainPage" x:Class="OouiWXF.MainPage">
`
</ContentPage.BindingContext>`
<Label x:Name="StartNarrative" Text="{Binding pStartNarrative, Mode=TwoWay}" />
and then in MainPage.cs class definition:
static public MainPageViewModel pMainPageViewModel;
and in the constructor:
pMainPageViewModel = (MainPageViewModel)this.BindingContext;
Here is a repository with the complete code: https://bitbucket.org/MarkStegaOHI/oouiwxf/src/develop/
Thanks to @zbigniew-gajewski for the dll & wasm types in the web server project; I've been meaning to get to this for a while.
I'm not able to get a view model bound via XAML. If I set it after the InitializeComponent call in the page constructor, it works though.
Checked in an example: https://github.com/solatticus/Ooui.Samples