XPlat, IStart vs IElmishViewModel and resolving fields #16
Replies: 11 comments 29 replies
-
Disregard - I found it - switched <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> to 'false' and the mappings switched from errors to warnings. 👍 https://docs.avaloniaui.net/docs/next/basics/data/data-binding/compiled-bindings#type-casting |
Beta Was this translation helpful? Give feedback.
-
Hey can I bother you to eyeball this project (SunFlwrXPlat) to see what I might have missed in trying to get it to work? I'm essentially just trying to get Elmish.Avalonia's sample app in XPlat format to then deploy to Android and iOS - for kicks. Right now I'm only seeing the UI render with "dead" menu links and no nav reaction to the menu bar. Can you weigh in? It looks like the bindings are dead - something I left out? Something I did that I shouldn't have done? |
Beta Was this translation helpful? Give feedback.
-
At some point I renamed I took a glance at your project. The only thing that seems weird is that I don't see a Program.fs anywhere. That has some configuration in it that is necessary. |
Beta Was this translation helpful? Give feedback.
-
The more I look at this the more confused I get. I just looked at your AvaloniaXPlatExample.fsproj for a package ordering difference, and spotted that there's not Program.fs for the project to "see" <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="ViewModels\IElmishViewModel.fs" />
<Compile Include="ViewModels\CounterViewModel.fs" />
<Compile Include="ViewModels\MainViewModel.fs" />
<Compile Include="Views\CounterView.fs" />
<Compile Include="Views\MainWindow.axaml.fs" />
<Compile Include="Views\MainView.axaml.fs" />
<Compile Include="App.axaml.fs" />
<Compile Include="ViewLocator.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="Elmish.Avalonia" Version="$(AvaloniaElmishVersion)" />
</ItemGroup>
</Project> src/Samples/AvaloniaXPlatExample/AvaloniaXPlatExample/AvaloniaXPlatExample.fsproj |
Beta Was this translation helpful? Give feedback.
-
I just created a new Avalonia.XPlat from the JaggerJo template and it also doesn't have a Program.fs at the top level. (They're there in Browser and Desktop) |
Beta Was this translation helpful? Give feedback.
-
Each supported plastform has a different start point (it's the same for MAUI). For example, desktop app still uses Program.fs, but Android has a main Activity. For example, your Android binding is still using |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Here is a link to the closed issue from @daz10000 where he was wrestling with similar issues: It may be helpful. |
Beta Was this translation helpful? Give feedback.
-
playing catch-up here I’m just reading the whole thread, but you ran into the main problem encountered getting the cross platform solution. At the highest level, web, mobile can only do a single window, so you end up with a top level control. The desktop has the flexibility to open many windows, and so it’s initialized differently. I never tested mobile, but in theory the web case should exercise all of the same problems as mobile (or at least a subset of them). If there are changes you want to make sure that example, please send them over. I didn’t have the ability to test android and iOS.DarrenAm 7/27/23 um 1:35 PM schrieb Jordan Marr ***@***.***>:
Re: odd chart behavior:
You should be tracking the isAutoUpdating state in the Model rather than having loose, static, mutable state.
All state changes should be in Model and should be managed via dispatching messages.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
you are going through the exact evolution I did. The dual head (window and user control) is a bit annoying, but ultimately you get used to it and you realize that these platforms are fundamentally single views of a multi window paradigm doesn’t make sense. I think the next layer of problems last thinking is how you switch between views, and Jordan help me work through all of the wiring to switch. You have to think about the user experience a little bit. You can’t click on an item in a list and just throw off a new window (I guess a tab in the browser world is the equivalent of opening a fresh window but that’s also a little bit hard to do with the overhead of starting up a new wasm session). Am 7/29/23 um 8:55 AM schrieb Houston Haynes ***@***.***>:
I honestly don't mind it so much. Other than that first view everything else is 1:1. Your point about multiple windows is interesting - like the Catalyst apps in MacOS running things like a tablet format - very "flat". I wonder if it's possible to point the "lifetime" for desktop to the MainView - I got from the docs that it needs a Window - not a Control. So there's that possible wrinkle. Begs the question whether mobile can start with a "Window" Control - which would make them more harmonious.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
For posterity (mainly my future self) here's an interesting excerpt while glancing at Fabulous.Avalonia... it seems they do the same thing - wrapping the viewmodel with a "Window" when in desktop lifetime. https://github.com/fabulous-dev/Fabulous.Avalonia /// A simple Counter app
type Model =
{ Count: int }
type Msg =
| Increment
| Decrement
let init () =
{ Count = 0 }
let update msg model =
match msg with
| Increment -> { model with Count = model.Count + 1 }
| Decrement -> { model with Count = model.Count - 1 }
let view model =
VStack(spacing = 16.) {
Image(ImageSource.fromString "fabulous.png", Aspect.AspectFit)
TextBlock($"Count is {model.Count}")
Button("Increment", Increment)
Button("Decrement", Decrement)
}
#if MOBILE
let app model = SingleViewApplication(view model)
#else
let app model = DesktopApplication(Window(view model))
#endif |
Beta Was this translation helpful? Give feedback.
-
Hey Jordan I'm wondering about a few things as I'm trying to migrate some of my work in the Example app over to an XPlat instance. I'm curious about some of the differences in stucture - like using "IStart" instead of IElmishViewModel - and whether that has something to do with a wrinkle in XPlat...
I'm also trying to get the project to build and right now I'm seeing hard errors in AXAML files in the XPlat project that are just warnings in the original example project. See the attached screen shot. (left is my XPlat and right is the example app I PR'd back to your repo) I always kinda 🤔 scratched my chin about why those warnings are there, and trusted that they're not an issue since that's a key to making things work in the Elmish binding model.
But now that it's a hard stop in this project I'm curious if this is a Jetbrains/IDE level setting or if there's something in Avalonia that needs to be set in order to get past it. Any thoughts? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions