8)MVVM Pattern실습 + Builder Pattern +이벤트처리 방법 관련질문
미해결
MAUI [Cross-Platform Applications & C#]
프로젝트 따라가면서 이해안되는 부분이있어 질문 남깁니다! mvvm 바인딩이 안되는것같아 질문드립니다. ( 다른파일 ex) listdetaileasyviewmodel은 잘됩니다) firstpage 관련 강의를 따라가고 있던중 binding 이안됩니다... 올려주신 학습자료는 .net 8.0 으로 변경후 (.net 7.0은 지원중단되어 안되더라구요 ) 실행하면 firstpage에서 binding이되어 중단점이 찍히는것을 확인했으나 .net 9.0 환경에서 작성한 코드가 binding이 DataRefresh 에 안찍힙니다. firstpage xaml에서 binding에 자동완성으로 DataRefreshCommand 가 뜨는 것은 확인했습니다. 혹시 실수를 하였나 다시 살펴봐도 오타가있거나 경로를 잘못하였나 살펴봐도 다른점이없는데 혹 .net 9.0에서 바뀐것이 있는지 다른 설정을 해줘야하는것이 있는지 궁금합니다. 혹시몰라 코드 첨부합니다. [FirstViewModel.cs] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MAUI_MVVM_STUDY2.ViewModels { public partial class FirstViewModel : BaseViewModel { [ObservableProperty] Person person; //함수와 연결하고자 할때는 xaml 에서 ClearCommand를 바인딩해주면됨 //비동기 함수로 생성할 경우 aync키워드를 동일하게 사용해주면됨 [RelayCommand] public async void DataRefresh() { Person abc = new Person(); abc = new Person(); abc.Age = 30; abc.Name = "KIM"; this.Person = abc; } } } [FirstPage.xaml] <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns=" http://schemas.microsoft.com/dotnet/2021/maui " xmlns:x=" http://schemas.microsoft.com/winfx/2009/xaml " x:Class="MAUI_MVVM_STUDY2.Views.FirstPage" xmlns:vm="clr-namespace:MAUI_MVVM_STUDY2.ViewModels" xmlns:m="clr-namespace:MAUI_MVVM_STUDY2.Models" x:DataType="vm:FirstViewModel" xmlns:toolkit=" http://schemas.microsoft.com/dotnet/2022/maui/toolkit " Title="FirstPage"> <VerticalStackLayout> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> <Label Text="{Binding Person.Age}"/> <Button Text="hello" IsEnabled="True" > <Button.Behaviors> <toolkit:EventToCommandBehavior EventName="Clicked" Command="{Binding DataRefreshCommand}" /> </Button.Behaviors> </Button> </VerticalStackLayout> </ContentPage> [AppShell.xaml 일부 ] <ShellContent Shell.NavBarIsVisible="true" Title="First" Icon="icondrawing.png" ContentTemplate="{DataTemplate views:FirstPage}" Route="FirstPage" /> [mauiprogram.cs 일부] builder.Services .AddSingleton<FirstPage>(); builder.Services .AddSingleton<FirstViewModel>(); 이상입니다. 학습자료의 코드와 다른점을 아무리 찾아봐도 안보이는데 따로 해줘야할것이 있을까요?
- ios
- C#
- azure
- cross-platform
- maui





