Mustafa
Mustafa
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
When I restart the application, I can see the task I added
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
@canton7 I solve this but now the views connected to the parentviewmodel and the view connected to the taskviewmodel where my tasks are displayed do not work synchronously
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
I think it would be better if I made the view task part of adding Priority and categories in the same view and connected the whole view to the parentviewmodel.
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
If I remove the TaskViewModel from the parentviewmodel, how will my priority view access the taskviewmodel?
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
So my previously selected priority specific taskview model is restarted
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
When I click the add task button in the view where my editors and buttons are located, it calls the taskviewmodel again.
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
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
CC#
Created by Mustafa on 9/9/2024 in #help
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
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
If I connect all my views to the parentviewmodel, it will unnecessarily run other viewmodels every time. For example, where my editors are, it is enough to call only 1 viewmodel.
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
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
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
This is the view where the task name and description are located and also the task add button is located.
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
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
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
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
CC#
Created by Mustafa on 9/9/2024 in #help
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; }
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
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
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
I'll explain it more clearly then
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
Since the view depends on the parentviewmodel, shouldn't the taskviewmodel be created there?
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
I can't get the value I selected from the picker in the viewmodel
Not resolved when deleting from ParentViewModel
68 replies
CC#
Created by Mustafa on 9/9/2024 in #help
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; }
68 replies