wpf

Catching an unhandled exception prior to it reaching Application level

We use the Dispatcher to catch any unhandled exceptions in our WPF app. This is defined in our app.xaml.cs file and it works very well. However we have a situation where we want to detect and trap any unhandled exceptions that happen in a specific WPF User Control. We would like to be able to intercept any unhandled erros related to that...

Stack overflow when opening menu with ApplicationCommands in C#

When I add an ApplicationCommands command to a MenuItem in my file menu, no matter via XAML or via code, when I open the menu the application crashes in a stack overflow, with absolutely no details about the problem. When I remove the Command, the problem also disappears. It doesn't matter which ApplicationCommand I use. Part of the cal...

Using the WPF Dispatcher in unit tests

I'm having trouble getting the Dispatcher to run a delegate I'm passing to it when unit testing. Everything works fine when I'm running the program, but, during a unit test the following code will not run: this.Dispatcher.BeginInvoke(new ThreadStart(delegate { this.Users.Clear(); foreach (User user in e.Results) { t...

WPF - Lock Position and size on a canvas

I have a canvas that I can create and drop elements onto. I can move them and size them with a thumb or through binding to a property grid. Now, I need to implement a feature to "lock" position and size. I started with try and set min and max height\width to the actual height\width. The initial effort wasn't so great. And I still don'...

WPF DataGrid how to get when ItemsSource updates

Which event fires when DataGrid's source is updating? I've tried DataContextChanged and SourceUpdated but it never worked out. Actually I need a simple thing. I want, if there is a new row comes, scroll the GridView's scrollbar down to the bottom to see what it was. ...

WPF layout issue

Hello, I have an issue with how to organise the the screen layout for my data. I have a object A with properties A1 and A2 and may contain an Object B. Object B has properties B1, B2, B3 and a collection of 1 or more of object C. Object C contains properties C1, C2 and C3 I want the the layout to be A1 A2 or A1 A2 B1 B2 ...

Using a XAML file as a vector Image Source

I would like to be able to use vector graphics, preferably defined in XAML, as the Source of an Image control, just like I can currently use a raster image like a PNG. That way I could easily mix and match between bitmap and vector images, like this: <StackPanel> <Image Source="Images/Namespace.png"/> <Image Source="Images/Modul...

How to get WPF xaml content by code on form C#

I design a form in WPF project. The xaml content is automatically generated based on the GUI I design (drag/drop,set position on GUI). How can I read/retreive the xaml content data by code in C# on form? ...

Set default browser when debugging WPF?

I'm using VWD Express 2008 to develop a WPF Browser Application. When I start debugging, it launches the XBAP in my default browser, which is Opera. Obviously, XBAPs don't work in Opera, so I have to repeatedly right-click on the document to open in IE. Is there any way to change the settings for PresentationHost.exe so that it always o...

WPF routed events , tunneling and bubbling

What is the thinking/philosophy behind having tunneling before Bubbling and not viceversa . ...

WPF Usercontrol with textboxes

I have a WPF user control with a number of textboxes, this is hosted on a WPF window. The textboxes are not currently bound but I cannot type into any of them. I have put a breakpoint in the KeyDown event of one of the textboxes and it hits it fine and I can see the key I pressed. The textboxes are declared as <TextBox Grid.Row="3"...

Anything similar to WPF's ValueConverters for ASP.Net ?

After doing a project with WPF and getting very much attached to it's excellent databinding capabilities, I have now moved back to ASP.Net and am starting to miss some of WPF's stuff. My question is...is there anything similar to WPF's ValueConverters for ASP.Net? For example, I want a UserControl to expose a public property which is a...

Code-behind for DataTemplate defined in a ResourceDictionary

I've defined a DataTemplate in a ResourceDictionary. The template need some data (for populating a ListBox). Previously the template was a UserControl and the data was provided by setting the DataContext property. Is there some way of using code-behind for a DataTemplate or is using an ObjectDataProvider to provide the data the only opt...

Excel & WPF modal form

I've got this situation. (.net 3.5) A Winform application that with OleAutomation and Office Interop create an excel, a toolbar and handlers for buttons in the toolbar. Now we've got some functionality that shows the user modal windows (winform 2.0) with the method: form.ShowDialog(new ExcelHwndWrapper(objExcelApplication.HWND)) And...

Working with WPF & SQL database

I'm into creating a simple contact management application to test how WPF works with SQL database. is there any WPF-code for that shows how to connect with SQL database ? save and update data? I'm using KaXML/Sharp-develop for WPF and using SQLite/MS-SQL server 2005. I can't use Visual studio express(not allowed to install,anyway that'...

Prism, Event published in shell not caught in module!

Hi, I have a wpf composite application with 3 or 4 modules that will always be loaded. In my shell I have a toolbar with buttons to active corresponding views from these modules. I injected an IEventAggregator into the shell presentor so that when a button is pressed I can publish an event that the corresponding module controller has sub...

MVVM WPF Creating Child Elements

I have a Customer object which has a List of Orders. Now, using MVVM pattern I am displaying a list of customers which is part of the CustomerOrderViewModel and "CustomerOrderView". The customers are shown using a listbox as implemented below: <ListBox BorderThickness="0" Grid.Column="0" Grid.Row="0" ItemsSource="{Binding Path=Custom...

How to use the same RoutedCommand in distinct controls ?

Hi, I a have 2 distinct UI elements in distinct files : a menuItem (in window.xaml) and a userControl (in foo.xaml). Both have exactly the same logic : they are enabled only if a condition is matched and call the same method. To code this logic, i use RoutedCommands. I could use 2 different RoutedCommands in each file with same condit...

Set TextSearch.Text for WPF-ComboBoxItem via DataTemplate

Hi Everybody, I use a datatemplate to visualize some items in a ComboBox, the ItemsSource is bound to an ObservableCollection. To keep it simple, let's say I put persons into the ObservableCollection: public class Person { public string FirstName { get; set; } public string LastName { get; set; } } My DataTemplate looks like ...

Can I run a windows presentation foundation app the way I would run a aspnet app?

Can I run a windows presentation foundation app on a webserver over the internet, or does it run like a windows app where I have to download the code to each pc? ...