I can't get the value I selected from the picker in the viewmodel
I select a value from the Picker. I see that it changes in the OnPropertyChanged() method in my ViewModel, but the value I select in the Task creation method is reset
43 Replies
Please post full source files, not little snippets. You may know how the different snippets tie together, but we have no idea
Hi
These are my taskviewmodel
Hi
Can you post as text files, rather than images of text?
The images are blurry, I can only look at one at a time, and I can't search them
Ok
I am attaching the following code where I have updated a list of collections (ObservableCollection), in the form of an array, to be able to store each Int32 element. Additionally, I have added a method to allow us to select each Int32 element.
public class ParentViewModel
{
public CustomerViewModel CustomerViewModel { get; }
public ProjectViewModel ProjectViewModel { get; }
public ActivityViewModel ActivityViewModel { get; }
public CategoryViewModel CategoryViewModel { get; }
public TaskViewModel TaskViewModel { get; }
public ParentViewModel()
{
var httpClient = new HttpClient { BaseAddress = new Uri("https://localhost:7017/") };
CustomerViewModel = new CustomerViewModel(new CustomerRepository(httpClient));
ProjectViewModel = new ProjectViewModel(new ProjectRepository(httpClient));
ActivityViewModel = new ActivityViewModel(new ActivityRepository(httpClient));
CategoryViewModel = new CategoryViewModel(new CategoryRepository(httpClient));
TaskViewModel = new TaskViewModel(new TaskRepository(httpClient));
}
}
}
And u can modify xaml code like this:
And what's the problem, exactly? I can't see any code which reads
NewPriority
, but you said that it's "reset" in "the Task creation method"?I am getting data from several viewmodels in the View, so I connected it to the parent viewmodel
And when I select the priority value from the Picker, I see that the value changes in onpropertychanged, but the NewTaske priority is 0.
U need to have
OnPropertyChanged()
on every ObservableCollectionIf I connect my Priority view directly to the taskviewmodel, my problem is solved, but this time the other picker objects in my view cannot receive the objects they receive from other viewmodels.
Only if it's assigned. ObservableCollections often aren't assigned