Qwerz
Qwerz
CC#
Created by armoiredu44 on 9/15/2024 in #help
how to see the console programm output in vs, WPF
I personally liked using Trace from System.Diagnostics . . .
4 replies
CC#
Created by Qwerz on 9/13/2024 in #help
Blazor Forms and Different Sessions
This is my first Blazor project, so I'll have to look into services and concern separation as a whole, I assume they work similar to WPF. Right now, my main focus is to get things working in a stable manner. Thank you for your help so far!
14 replies
CC#
Created by Qwerz on 9/13/2024 in #help
Blazor Forms and Different Sessions
You all seem to be right. I do wonder however, why my coworker experienced the issues he described. Generally speaking, would you approve of my methodology for creating a public contact form on a homepage?
14 replies
CC#
Created by Qwerz on 9/13/2024 in #help
Blazor Forms and Different Sessions
I will try again, thanks!
14 replies
CC#
Created by Qwerz on 9/13/2024 in #help
Blazor Forms and Different Sessions
Do I not need sessions for this? Isn't the model used in the form a static object and thus always the same for any client?
14 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
Thanks for the tip, I will implement it this way once I progress further!
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
This basically decribes your example from above, right? I just finished implementing it this way in my project and it works like a charm! The best thing is, it still feels MVVM conform and I can definitely see myself using something similar in many future situations. MVVM is straightforward...to those who already excel at it it seems 😉 I've been learning the pattern for this past year and I still find myself trapped in simple problems like these. Thanks again for taking the time to help me out, very much appreciated!
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
Thank you very much, this is the smartest solution i did not think of! I will get this working.
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
You're right, my CarModel is your ChildViewModel. I was thinking there was a difference with some deeper meaning between Model and ViewModel?
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
I have seen multiple VMs (your example) used in ItemControls before, but I didn't see any advantage in it and just continued doing it like I was used to.
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
I have: TestView.xaml
c#
<ItemsControl ItemsSource="{Binding Cars}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TimeRemaining}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
c#
<ItemsControl ItemsSource="{Binding Cars}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding TimeRemaining}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
TestViewViewModel.cs
c#
private ObservableCollection<CarModel> cars;
public ObservableCollection<CarModel> Cars{
get => cars;
set{cars = value;
OnPropertyChanged();}
}

public TestViewViewModel(){
cars = new ObservableCollection<CarModel>();
}
c#
private ObservableCollection<CarModel> cars;
public ObservableCollection<CarModel> Cars{
get => cars;
set{cars = value;
OnPropertyChanged();}
}

public TestViewViewModel(){
cars = new ObservableCollection<CarModel>();
}
(simplified)
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
In the meantime, I thought I could maybe use OnPropertyChange in the get method of a property of minutes, but that seems to be impractical and not work at all.
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
Thanks for expanding on this. I'm confused because I can't quite identify why using two ViewModels is necessary or solved the problem at hand (periodically updating collection of objects in an items control). I have a very similar setup, the difference being that I don't have a child VM but only a ViewModel for my View. Thus I'm still stuck on implementing a solution using a single timer instead of one for each object in the list. I'm also curious to understand whether using two VMs is beneficial / the "correct" way? Thank you!
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
Well yes, but I only have one viewmodel that is in my views datacontext to which I can bind. You're suggesting to use two view models, making me unsure if I can get away with using one?
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
I guess I deviated from the norm a little then. I’m using a single viewmodel and view, where I have a listbox with data template that binds to a collection in the viewmodel. And yes, I would like to show the countdown in the list. Do you have an idea where I could get an example for the timer per object implementation? It would really help to see how others have gone about doing this.
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
So you’d have two views (one used as a component) and two corresponding nested view models? Why not just use one view model? I’m, sorry but I’m a bit confused by having a collection of viewmodels. Could you explain this please? I’m always eager to learn if there’s a better way!
33 replies
CC#
Created by Qwerz on 8/26/2024 in #help
✅ How do you handle countdowns of objects?
My problem with the approach of having a separate collection that is refreshed via a timer is that I’m not sure how to reference it in my View and bind to it, because it’s a different datacontext than the viewmodel I’m using. I can’t wrap my head around how to structure this in a meaningful way, how to keep track of each objects expiration. I’m a bit surprised there’s no easy example because I thought this was something relatively commonly implemented.
33 replies
CC#
Created by Qwerz on 5/15/2024 in #help
Adding items to an observable collection from 'outside' (MVVM)
Alright, I get the approach but I'm still not sure how to call this from the BL in a static context? I see you're using a relay command, but that doesn't help me when I want to add an event from an otherwise completely unrelated class, right? Could you please include an example of how I would call the AddEvent() function from "somewhere" else?
14 replies
CC#
Created by Qwerz on 5/15/2024 in #help
Adding items to an observable collection from 'outside' (MVVM)
Thank you so much for taking the time to help me out, I really really appreciate it! It will take me some time to test this out and work around community tool kit - I will get back as soon as I have come around to doing that.
14 replies
CC#
Created by Qwerz on 5/15/2024 in #help
Adding items to an observable collection from 'outside' (MVVM)
Oh I can relate...😅 Without spilling too much salt; I also find it quite difficult to outsource features in the team. My favourite: new views are not implemented into the MVVM navigation, but are opened using dialogs -.- . I'm having a tough time to pass anything UI related onto one of my coworkers, because what's produced rarely fits the projects structure. Anyways, I can't do everything on my own, and vast parts of the BL are unbeknown to me. I'm also not really in a leading position, but I'm charged to oversee the GUI aspect and UX decisions. Hence my preference to produce a static function. In the mid-term I plan on suggesting everyone (myself included) take an extensive course, but right now we have to focus on getting the work done.
14 replies