반응형
if (!(BindingContext is DFDream dream)) return;
MessagingCenter.Send(this, MessagingCenterMessages.AddWizardDream, dream));
이렇게 하고 dream을 수정하니까 추가된 dream들이 다 같이 수정되어버림.
DFDream에 Clone() 메소드를 추가.
public object Clone()
{
return new DFDream
{
Id = this.Id,
ProfileImage = this.ProfileImage,
...
};
}
(DFDream)dream.Clone()으로 넘김.
private async void OnStartDreamButtonTapped(object sender, EventArgs e)
{
DependencyService.Get<IDFVibration>().VibrateShort();
if (!(BindingContext is DFDream dream)) return;
MessagingCenter.Send(this, MessagingCenterMessages.AddWizardDream, (DFDream)dream.Clone());
...
받는 곳에서는 id값을 변경.
MessagingCenter.Subscribe<DFDiscoverDetailPage, DFDream>(this, MessagingCenterMessages.AddWizardDream, async (sender, dream) =>
{
dream.Id = (++DFDreamSource.NumberOfLastID).ToString();
DFDreamSource.dreamSource.Add(dream);
DreamListToDisplay.Add(dream);
if (Navigation.NavigationStack.Count > 0)
{
try
{
await Navigation.PopAllPopupAsync();
}
catch
{
}
}
await Navigation.PushPopupAsync(DreamAddedPopup.Instance);
});
버그 해결!
반응형
'프로그래밍 > App 개발' 카테고리의 다른 글
[Xamarin] Custom sliver top area (gradually disappearing view while scrolling) (0) | 2021.09.13 |
---|---|
[Xamarin] set alpha at hex (0) | 2021.06.16 |
[Xamarin] Draw dashed(dotted) arc with SkiaSharp (not using AddArc()) (0) | 2021.06.14 |
[Xamarin] Draw Arc with SkiaSharp (0) | 2021.06.14 |
[Xamarin] custom keyboard attachable view (0) | 2021.06.09 |