mvvm

SwiftUI + Combine, using Models and ViewModels together

我的未来我决定 提交于 2021-02-08 10:18:17
问题 I'm very new to Swift and I am currently trying to learn by building a rent splitting app with SwiftUI + Combine. I want to follow the MVVM pattern and am trying to implement this. At the moment I have the following Model, ViewModel and View files: Model: import Foundation import Combine struct InputAmounts { var myMonthlyIncome : Double var housemateMonthlyIncome : Double var totalRent : Double } ViewModel (where I have attempted to use the data from the Model to conform to the MVVM pattern,

How generate(binding) quiz in form using wpf mvvm

我怕爱的太早我们不能终老 提交于 2021-02-08 07:25:59
问题 How binding quiz with different type questions in WPF app using MVVM? QuizPageViewModel: public class QuizPageViewModel : ViewModelBase { public QuizPageViewModel() { QuizCollection = new ObservableCollection<QuizQuestion>(); } public ObservableCollection<QuizQuestion> QuizCollection { get; set; }} Where QuizQuestion : - EF Entity public partial class QuizQuestion { public QuizQuestion() { QuizAnswers = new HashSet<QuizAnswer>(); QuizMultiQuestions = new HashSet<QuizMultiQuestion>(); } public

How generate(binding) quiz in form using wpf mvvm

[亡魂溺海] 提交于 2021-02-08 07:23:54
问题 How binding quiz with different type questions in WPF app using MVVM? QuizPageViewModel: public class QuizPageViewModel : ViewModelBase { public QuizPageViewModel() { QuizCollection = new ObservableCollection<QuizQuestion>(); } public ObservableCollection<QuizQuestion> QuizCollection { get; set; }} Where QuizQuestion : - EF Entity public partial class QuizQuestion { public QuizQuestion() { QuizAnswers = new HashSet<QuizAnswer>(); QuizMultiQuestions = new HashSet<QuizMultiQuestion>(); } public

How generate(binding) quiz in form using wpf mvvm

帅比萌擦擦* 提交于 2021-02-08 07:20:08
问题 How binding quiz with different type questions in WPF app using MVVM? QuizPageViewModel: public class QuizPageViewModel : ViewModelBase { public QuizPageViewModel() { QuizCollection = new ObservableCollection<QuizQuestion>(); } public ObservableCollection<QuizQuestion> QuizCollection { get; set; }} Where QuizQuestion : - EF Entity public partial class QuizQuestion { public QuizQuestion() { QuizAnswers = new HashSet<QuizAnswer>(); QuizMultiQuestions = new HashSet<QuizMultiQuestion>(); } public

SwiftUI updating UI with high frequency data

▼魔方 西西 提交于 2021-02-08 06:51:30
问题 I'm trying to update the main view with high frequency data coming from separate background thread. I've created two tabviews and in case of slow update rate I can change the view. But in another case the UI doesn't react. I've observed this behavior only on real device, in the simulator works everything fine. The while loop is still representing an imu, just to keep it simple. Did someone any idea how to fix this issue? Many thanks! import SwiftUI struct ContentView: View {

SwiftUI updating UI with high frequency data

守給你的承諾、 提交于 2021-02-08 06:51:21
问题 I'm trying to update the main view with high frequency data coming from separate background thread. I've created two tabviews and in case of slow update rate I can change the view. But in another case the UI doesn't react. I've observed this behavior only on real device, in the simulator works everything fine. The while loop is still representing an imu, just to keep it simple. Did someone any idea how to fix this issue? Many thanks! import SwiftUI struct ContentView: View {

In MVVM pattern what is the recommended order of instantiation? [closed]

左心房为你撑大大i 提交于 2021-02-08 04:39:44
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 7 years ago . Improve this question I got this asked in an interview recently . He wanted to know the order of instantiation of Model View and ViewModel what the precise order of instantiation would be ? I thought the view is always instantiated first and then comes the viewmodel and then

Command binding to ViewModel with confirmation logic in View

眉间皱痕 提交于 2021-02-07 21:51:36
问题 Looking for the most elegant solution to bind a button command to a ViewModel ICommand property, while allowing confirmation in the View. What I would like to do: Only allow a user to click a button when he/she should When the button is clicked, ask a confirmation If comfirmed, do work in the ViewModel, otherwise cancel Do not break MVVM architecture The confirmation requirement can be fulfilled by showing a messagebox from the ViewModel. However, I don't think this is the way to go. Doesn't

Presenting an Alert in SwiftUI using MVVM

泪湿孤枕 提交于 2021-02-07 20:13:50
问题 I'm trying to build an app using SwiftUI and an MVVM architecture. I'd like to have my View present an alert whenever its ViewModel deems it necessary—say, when it has a new result of some sort available from the Model. So suppose whenever the VM detects a new result it sets its status accordingly: The ViewModel: enum Status { case idle case computing case newResultAvailable } class MyViewModel: ObservableObject { @Published var status = Status.idle ... } The View: struct ContentView: View {

Page with type parameter

北战南征 提交于 2021-02-07 19:27:46
问题 I would like to use new feature of UWP -> x:Bind. In order to that, all my pages need to have ViewModel property (as described in tutorials). To avoid code duplicity, I have established base class as follows: public abstract class BasePage<TBaseVM> : Page, where TBaseVM : BaseVM { public TBaseVM VM { get; private set; } protected BasePage() { DataContextChanged += (s, e) => VM = e.NewValue as TBaseVM; } } As you can see this BasePage class contains property called "VM" and property is of type