Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser mvvm error #15944

Closed
bbhxwl opened this issue Jun 7, 2024 · 4 comments
Closed

Browser mvvm error #15944

bbhxwl opened this issue Jun 7, 2024 · 4 comments
Labels

Comments

@bbhxwl
Copy link

bbhxwl commented Jun 7, 2024

Describe the bug

The browser's display of text is also abnormal, and it cannot be automatically updated by MVVM, but Windows can function normally.

using ReactiveUI;

namespace AvaloniaApplication2.ViewModels;

public class MainViewModel : ViewModelBase
{
    private string _greeting =  "Welcome to Avalonia!";
    public string Greeting
    {
        get => _greeting;
        set => this.RaiseAndSetIfChanged(ref _greeting, value);
    }
}
using Avalonia.Controls;
using Avalonia.Interactivity;
using AvaloniaApplication2.ViewModels;

namespace AvaloniaApplication2.Views;

public partial class MainView : UserControl
{
    MainViewModel viewModel;
    public MainView()
    {
        InitializeComponent();
        viewModel=new MainViewModel();
        DataContext = viewModel;
    }

    private void Button_OnClick(object? sender, RoutedEventArgs e)
    {
        viewModel.Greeting = "11111111111";
    }
}

image
image
image

To Reproduce

AvaloniaApplication2.zip

Expected behavior

No response

Avalonia version

11.0.10

OS

No response

Additional context

No response

@bbhxwl bbhxwl added the bug label Jun 7, 2024
@rabbitism
Copy link
Contributor

image
Because in browser app it goes to this line and your data context is re-assigned after constructor.

@bbhxwl
Copy link
Author

bbhxwl commented Jun 7, 2024

image Because in browser app it goes to this line and your data context is re-assigned after constructor.

Thank you, I am a beginner. Thank you very much. I have used xamarin before. But now the dilemma is whether to learn Maui or this.

@rabbitism
Copy link
Contributor

You can join QQ group 397510870 if you want to learn more about Avalonia.

@bbhxwl
Copy link
Author

bbhxwl commented Jun 7, 2024

You can join QQ group 397510870 if you want to learn more about Avalonia.

+了。没同意呢还

@AvaloniaUI AvaloniaUI locked and limited conversation to collaborators Jun 7, 2024
@maxkatz6 maxkatz6 converted this issue into discussion #15946 Jun 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants