Mustafa
I can't get the value I selected from the picker in the viewmodel
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));
}
When choosing a priority, the taskview model is called here
68 replies
I can't get the value I selected from the picker in the viewmodel
TextEditorView.BindingContext = _taskViewModel;
JobsListView.BindingContext = _taskViewModel;
ProcessPropertiesView.BindingContext = _parentViewModel;
I was talking about this. Taskviewmodel is also called in ParentViewModel and if I delete taskviewmodel from parentviewmodel, this time priority view cannot access taskviewmodel functions.
68 replies
I can't get the value I selected from the picker in the viewmodel
The problem is that my buttons and the view where I set the priority are bound to different ViewModels. The view where I select the priority is in the ParentViewModel, which initializes the TaskViewModel. The view with the editors also initializes the TaskViewModel, and this causes a conflict.
68 replies
I can't get the value I selected from the picker in the viewmodel
Since I am currently connecting it to the Parentviewmodel, I connected the bindings by saying taskviewmodel. Normally, I did not write taskviewmodel because that is the only viewmodel it is connected to.
68 replies
I can't get the value I selected from the picker in the viewmodel
I think I found the cause of the problem. My button that triggers the AddTaskCommand is connected to the taskviewmodel. So when you press the button, it calls the taskviewmodel twice as you said.
68 replies
I can't get the value I selected from the picker in the viewmodel
The AddTaskCommand is bound to a button, and the button triggers the following code:
private async Task AddTaskCommandAsync()
{
var newTask = new TaskItem
{
TaskName = this.NewTaskName,
TaskDescription = this.NewTaskDescription,
TerminTime = IsTerminSelected ? FullTerminTime : null,
Priority = NewPriority
};
Console.WriteLine($"New Task created: TaskName = {newTask.TaskName}, Priority = {newTask.Priority}");
await _taskRepository.CreateTaskAsync(newTask);
Items.Add(newTask);
NewTaskName = string.Empty; NewTaskDescription = string.Empty; NewTerminTime = null; IsTerminSelected = false; }
NewTaskName = string.Empty; NewTaskDescription = string.Empty; NewTerminTime = null; IsTerminSelected = false; }
68 replies
I can't get the value I selected from the picker in the viewmodel
I am building a project manager application, and on my main page, I am calling four views. One of these views is a ListView where tasks are displayed, and another is a view where I select task-related details such as priority, customer, and categories. The third view contains editors where I enter the task's name, date, and description. There's one more view, but we don't need to focus on that right now.
The view with the task list is bound to the TaskViewModel because it only retrieves task-related information. The view where I enter the task's name, description, and date is also bound to the TaskViewModel. However, the view where I select task-related information like priority, customer, and category is bound to the ParentViewModel because it needs to retrieve data from multiple ViewModels, such as CategoryViewModel for categories and CustomerViewModel for customers.
If I don’t bind the view where I set the priority to the ParentViewModel, the customer and category data won't be retrieved. I tried removing the TaskViewModel from the ParentViewModel, but the problem persists because my view is bound to the ParentViewModel, and if I remove the TaskViewModel, I can no longer access its functions.
68 replies
I can't get the value I selected from the picker in the viewmodel
public partial class MainPage : ContentPage
{
private readonly TaskViewModel _taskViewModel;
private readonly ParentViewModel _parentViewModel;
public MainPage(TaskViewModel taskViewModel, ParentViewModel parentViewModel)
{
InitializeComponent();
_taskViewModel = taskViewModel; _parentViewModel = parentViewModel; // TextEditorView ve JobsListView için aynı ViewModel'i kullanıyoruz TextEditorView.BindingContext = _taskViewModel; JobsListView.BindingContext = _taskViewModel; ProcessPropertiesView.BindingContext = _parentViewModel; }
_taskViewModel = taskViewModel; _parentViewModel = parentViewModel; // TextEditorView ve JobsListView için aynı ViewModel'i kullanıyoruz TextEditorView.BindingContext = _taskViewModel; JobsListView.BindingContext = _taskViewModel; ProcessPropertiesView.BindingContext = _parentViewModel; }
68 replies