티스토리 뷰
한페이지 Multiview BindingContext 구현은 View 한개에 두개의 모델을 넣으면 된다...
<Page1.cs>
BindingContext = new Page1_ViewModel();
<View에서>
public class Page1_ViewModel
{
public ObservableCollection<EduPoint_List> Bind_Edu_List { get; private set; }
public ObservableCollection<RTDB_Notice> Notices
{
get { return _Notices; }
set
{
_Notices = value;
OnPropertyChanged();
}
}
List<EduPoint_List> source;
public Page1_ViewModel()
{
// Binding 1 -----------
source = new List<EduPoint_List>();
CollectionView collectionView = new CollectionView
{
RemainingItemsThreshold = 5
};
source = Edu_Binds().Result;
if (source is null)
{
//Console.WriteLine("Notice Null");
}
else
{
Bind_Edu_List = new ObservableCollection<EduPoint_List>(source);
if (Bind_Edu_List is null)
{
Console.WriteLine("Bind_Edu_List Null");
}
selectedItem = Bind_Edu_List.Skip(0).FirstOrDefault();
ItemSelectionChanged();
}
// Binding 1 END -----------
// Binding 2 START -----------
_RTDBservices = new DBFirebase();
firebaseHelper.listenForEvents(3);
Notices = firebaseHelper._returnedEvents;
if (Notices != null)
{
AddCommand = new Command(async () => await addNoticesAsync(RTDB_Subject, RTDB_Body));
}
// Binding 2 END -----------
}
public async Task<List<EduPoint_List>> Edu_Binds()
{
return await Page1.EduListBind();
}
ObservableCollection<object> selectedItems;
public ObservableCollection<object> Selected_Items
{
get
{
return selectedItems;
}
set
{
if (selectedItems != value)
{
selectedItems = value;
}
}
}
EduPoint_List selectedItem;
public EduPoint_List SelectedItem
{
get
{
return selectedItem;
}
set
{
if (selectedItem != value)
{
selectedItem = value;
}
}
}
public ICommand ItemSelectionChangedCommand => new Command(ItemSelectionChanged);
public void ItemSelectionChanged()
{
SelectedItemMessage = $"Selection {selectedItem}: {selectedItem.Subject}";
OnPropertyChanged("SelectedItemMessage");
selectionCount++;
}
public string SelectedItemMessage { get; private set; }
int selectionCount = 1;
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
FirebaseHelper firebaseHelper = new FirebaseHelper();
public async Task addNoticesAsync(string _RTDB_Subject, string _RTDB_Body)
{
Console.WriteLine("Add__________________________");
await _RTDBservices.AddNotices(_RTDB_Subject, _RTDB_Body);
}
return oc;
} // Close Page1_ViewModel
______________________________________
참고:
https://stackoverflow.com/questions/59661566/how-do-i-bind-multiple-viewmodels-to-a-single-view
'Xamarin' 카테고리의 다른 글
Xamarin.Forms tabbed page change tab programmatically (2) | 2021.07.26 |
---|---|
Xamarin.forms Active indicator Progmatically Loading (2) | 2021.07.08 |
StackLayout Label Fit the size not working (0) | 2021.05.28 |
iOS UiView CGRect Error (0) | 2021.05.03 |
Xamarin.Android reCAPTCHA (0) | 2021.04.13 |
- Total
- Today
- Yesterday
- 연산자 뒤에 피연산자가 없습니다.
- Xamarin Firebase Phone Auth
- Xamarin.Forms
- Xamarin.Ios Firebase Phone SMS OTP Send
- FileStream Add Byte
- Linux SSH Multi Computer Join
- WPF Scrollviewer in ScrollViwer
- Embeded 한글Font적용
- Xamarin reCAPTCHA
- WPF Datagrid Cell Value Change
- Xamarin SMS OTP Send
- SkiaSharp
- ClickOnce 인증서 인증기간 변경
- Xamarin.Ios Firebase Phone Auth
- WPF Excel Export Microsoft.Office.Interop 성능향상(열 기준으로 복사)
- 암호 마스터키
- WPF Textbox
- Microcharts
- 서버 수준의 URN 필터
- C# LINQ Left join
- Xamarin.Ios Firebase Phone User Add
- GetCellContent CheckBox Value
- c# Encrypt / Decrypt
- Entry '' has empty native path
- Windows IIS FTP 디렉토리 목록 오류
- Label Text LineBreak in Xaml
- Xamarin Firebase Phone User Add
- ssl_client_socket_impl.cc
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |