前提・実現したいこと
複数のReactivePropertyを内部クラスでまとめた場合のViewの書き方がわからないので質問させてください。
該当のソースコード
ViewModel
C#
1using Prism.Navigation; 2using Reactive.Bindings; 3 4namespace Test.ViewModels 5{ 6 public class MainPageViewModel : ViewModelBase 7 { 8 //実際には沢山のReactivePropertyが並ぶ 9 class TempSet 10 { 11 public ReactiveProperty<string> Label { get; set; } = new ReactiveProperty<string>(); 12 } 13 TempSet FastSet = new TempSet(); 14 public ReactiveProperty<string> Label2 { get; set; } = new ReactiveProperty<string>(); 15 public MainPageViewModel(INavigationService navigationService) 16 : base(navigationService) 17 { 18 FastSet.Label.Value = "ラベル"; 19 Label2.Value = "ラベル2"; 20 } 21 } 22}
View
xaml
1<?xml version="1.0" encoding="utf-8" ?> 2<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 3 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 4 x:Class="Test.Views.MainPage" 5 Title="{Binding Title}"> 6 7 <StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"> 8 <Label Text="{Binding FastSet.Label.Value}" /> 9 <Label Text="{Binding Label2.Value}" /> 10 </StackLayout> 11 12</ContentPage>
結果
この場合、<Label Text="{Binding FastSet.Label.Value}" />には何も表示されません。
どのように書けばよいのでしょうか?またはそもそもViewModelの書き方に問題があるのでしょうか?
補足情報
Xamarin.Forms/ReactiveProperty/Prism を使用しています。
回答2件
あなたの回答
tips
プレビュー