XE SparkyCracked
How do I "pre-load" a view model
I would like to Preload a WPF ViewModel While Showing a Loading Overlay.
I'm working on a WPF application using the MVVM pattern. I have a
ViewSelector
property that switches between views based on its value. I also have a loading overlay (ViewSelector = 4
) that I want to display while a ViewModel is being preloaded.
Here’s the problem: One of my views (ViewSelector = 1
) takes a long time to initialize because it loads a lot of data and performs heavy processing. I want to:
Show the loading overlay (ViewSelector = 4
) while this ViewModel is being prepared.
Load the heavy ViewModel in the background to keep the UI responsive.
Automatically switch to the target view (ViewSelector = 1
) when the background preparation is complete.
Here’s my current approach in the ViewModel's command:
This works but causes an issue because switching to ViewSelector = 1
itself involves heavy operations that block the UI if done synchronously. I’ve considered using BackgroundWorker
or other threading mechanisms but ran into problems with updating ViewSelector
on the wrong thread.8 replies
Threading issues, settter with ObservableCollection and ListCollectionView
I need assistance in understanding what is happening please.
I have an ObservableCollection which I would like to filter according to certain buttons being clicked. (Complete/Busy for example)
Now I created a ListCollectionView inside the set to handle the filtering, so the ListCollectionView will be shown on the UI while the ObservableCollection will be used as the data source.
The issue with this is the concept that I'd be creating a new ListCollectionView everytime the set is hit (everytime the
DisplayList
is changed)
Here is the snippet of code:
Upon trying to initialize my ListCollectionView in the contructor, I ended up with the following code:
I now get a threading issue upon trying to refresh. I am unsure what is happening.5 replies
✅ Guidance needed for encryption
Good day. I want to dive into creating my own encryption method/class. I want it to be similar to what the big companies do as I want to present it forward to the company I work at. They don't have their own encryption method.
I did some research and found the Rijndael algorithm and found it "a worthy" method. My main reason for asking for help is just to ask if you know any recourses or any existing open source methods that I can use to just guide me in completing this project.
If you know any other methods that are secure and also really well sourced please let me know. I am doing this project to further my knowledge with C# and actually have an impressive project to showcase if the company decides to not use it.
20 replies
✅ BackgroundWorker getting progress
I have a winform applications and with this I have put a ProgressBar on it. I was manually changing the progress inside functions using
progressBar.Value = <value>
but now that I run my functions in the background using BackgroundWorker, changing that progress is a little harder than I thought. If I am not mistaken the code below is defined as a 'Delegate Invocation' and I use it to run the function I would like to track progress of:
How can I give progress better?17 replies
Casting object to enum class
So I have:
And I wanna case my object to that class:
There is a reflector to determine what variable type it is but it kinda does this on runtime/compile.
I wanna know if there is a way to cast this without wrapping it
114 replies
✅ Winforms: open two forms at the same time
Good day everyone. So I have an issue (duhh, thats why I am here xD).
I am trying to get a screenshot of the users image...I am using two forms to achieve this, one to show the image and another to screenshot.
When I try open the first form
AspectRatioForm
and then the second SelectArea
. It throws the issue below:
This is the code I wrote:
Now I don't know why this is happening because if I call them separately in terms of their own functions using ShowDialog
they both show one by one (once one form closes the other will show).7 replies
Windows Form App - SharePoint Image Upload
Hello everyone,
I'm currently working on a Windows Form application using C# and have encountered an issue with uploading images to SharePoint. The objective is to allow users to upload images through the Windows Form, and I want these images to be reflected in a SharePoint table.
Here's a quick overview of my process:
1. Users upload images through the Windows Form app.
2. The app uploads images to SharePoint's siteassets.
3. The corresponding SharePoint table gets updated with image information.
The challenge I'm facing is that while the images successfully upload to SharePoint's siteassets, they don't appear in the SharePoint table.
Bellow is a snippet of code:
4 replies