160
votes
20answers
36k views
What is the correct way to create a single instance application?
Using C# and WPF under .net (rather than WindowsForms or console), what is the correct way to create an application that can only be run as a single instance? I know it has something to do with some ...
45
votes
2answers
8k views
Good or bad practice for Dialogs in wpf with MVVM?
I lately had the problem of creating add and edit dialogs for my wpf app.
All I want to do in my code was something like this. (I mostly use viewmodel first approach with mvvm)
ViewModel which calls ...
46
votes
8answers
41k views
Find all controls in WPF Window by type
I'm looking for a way to find all controls on Window by their type,
for example: find all TextBoxes, find all controls implementing specific interface etc.
86
votes
9answers
83k views
Load a WPF BitmapImage from a System.Drawing.Bitmap
I have an instance of a System.Drawing.Bitmap and would like to make it available to my WPF app in the form of a System.Windows.Media.Imaging.BitmapImage.
What would be the best approach for this?
149
votes
8answers
135k views
WPF image resources
I come from a mostly web and a little bit Windows Forms background. For a new project, we will be using WPF. The WPF application will need 10 - 20 small icons and images for illustrative purposes. I ...
39
votes
8answers
30k views
How to handle WndProc messages in WPF?
Finding WPF a steep learning curve.
In good ol' Windows Forms, I'd just override WndProc, and start handling messages as they came in.
Can someone show me an example of how to achieve the same ...
110
votes
17answers
50k views
WPF MVVM Newbie - how should the ViewModel close the form?
I'm trying to learn WPF and the MVVM problem, but have hit a snag.
This question is similar but not quite the same as this one (handling-dialogs-in-wpf-with-mvvm)...
I have a "Login" form ...
19
votes
10answers
22k views
How can I register a global hot key to say CTRL+SHIFT+(LETTER) using WPF and .NET 3.5?
I'm building an application in C# using WPF. How can I bind to some keys?
Also, how can I bind to the Windows key?
36
votes
8answers
27k views
Set focus on textbox in WPF from view model (C#) & wPF
I have a TextBox and a Button in my view.
Now I am checking a condition upon button click and if the condition turns out to be false, displaying the message to the user, and then I have to set the ...
41
votes
4answers
29k views
How can I programmatically generate keypress events in C#?
How can I programmatically create an event that would simulate a key being pressed on the keyboard?
26
votes
4answers
17k views
Using global keyboard hook (WH_KEYBOARD_LL) in WPF / C#
I stitched together from code I found in internet myself WH_KEYBOARD_LL helper class:
Problem this had is now solved, thanks to Mattias S, following YourUtils.cs is fixed.
Put the following code to ...
30
votes
6answers
11k views
How to add a Blend Behavior in a Style Setter
I have crated a Blend behavior for Button. How can I set that to all of my Buttons in the app.
<Button ...>
<i:Interaction.Behaviors>
<local:MyBehavior />
...
62
votes
6answers
188k views
Binding WPF ComboBox to a Custom List
I have a ComboBox that doesn't seem to update the SelectedItem/SelectedValue.
The ComboBox ItemsSource is bound to a property on a ViewModel class that lists a bunch of RAS phonebook entries as a ...
76
votes
6answers
28k views
WPF global exception handler
sometimes, under not reproducible circumstances, my WPF application crashes without any message. The application simply close instantly.
Where is the best place to implement the global Try/Catch ...
32
votes
7answers
23k views
No output to console from a WPF application?
I'm using Console.WriteLine() from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what ...