wpf

WPF/MVVM: TreeView structure from one ViewModel, check state from another?

I have a tree structure to be displayed on a WPF TreeView. The tree structure is shared between multiple parent ViewModels, but the check state will be different for each. Is it possible to make the TreeView use one ViewModel to create the tree nodes, and the CheckBoxes contained therein refer to a different ViewModel/whatever to determ...

Eat MouseDown event after closing a WPF menu

I'd like to implement a WPF menu with the same behavior as the Office menus: When you click away when the menu, it closes the menu but the clicked element does not receive a MouseDown event. I thought of a couple of ways to do this but they are horribly complex. Is there a relatively easy way to accomplish this? ...

Disabling controls based on WPF command/command bindings

Using commands is handy because WPF automatically disables the source of the command (typically a button) when the command can't be executed. Evidently, this feature is not available to controls that are not a command source e.g. ListBox. What is the best way to enable this feature for non command source controls. I thought of a couple...

Catching Unhandled Exceptions in Child Threads in WPF

I have a WPF application that spins off several threads. I have defined a DispatcherUnhandledException event handler in App.xaml.cs that displays a detailed error message, and this handler gets called every time the UI thread encounters an exception. The problem is with the child threads: their unhandled exceptions never get handled. How...

Where can I find one of these "devigners" or "developer designers"?

My company is doing a fair bit of WPF and Silverlight development recently and we are discovering that while we are darn good at slinging code, our UI design skills lack some "pizazz". Where does one find a "devigner", as Microsoft calls them? Are there user groups (especially in the Dallas area) with these types of artists/usability ex...

play audio in an embedded media player

I have a client station that downloads .wav file and plays with the embedded medai player by using AxWindowsMediaPlayer library. I need to download the audio and give the url of the file to my media player. I was just wondering if there is any way that I don't store it in a physical storage, and load it from a memory for the media player...

WPF Mouse Over

What is the best way to link a method when the mouse over event is fired? An example. when a mouse hovers over a button. A method fires such as count. So as long as the mouse is over the button, the count will keep on incrementing. How will i connect a mouse over event to a method? Using Xaml?! ANY IDEAS?! ...

WPF: Making the Target property refer to a control in WindowsFormsHost

In WPF, you can assign a label a mnemonic, and tell it which control to activate with the "Target" property. This doesn't work if the target is a WindowsFormsHost. Is there a known solution to this? Here's an example. I am trying to make ALT-S activate the masked text box. <Label Width="Auto" Target="{Binding ElementName=tbSta...

WPF MVVM Drag and Drop onto another Control to raise an event only

I've got two ListBox's with objects as an ItemsSource populating them. Right now, I'm using a DragDropHelper to let me drag an object from one ListBox to the 2nd ListBox. I run custom code to change an attribute on the Object and update my two ListBox collections of objects. However, now I want to be able to drop one of these objects on...

WPF Mixing Bound and Fixed text in a TextBox

I have the following code to display a clients age. <TextBox x:Name="txtClientAge" Text="{Binding Path=ClientAge}" /> However, instead of just displaying just the number, I want to prefix it with the text "Age " and suffix it with the text " yrs" so it is effectively becomes "Age 36 yrs" I can achieve this with a horizontal StackPane...

Dragging and dropping to a TreeView, finding the index where to insert the dropped item

I have a WPF treeview with one level of child items. I am using the HierarchicalDataTemplate for the top-level items, so the child items are bound to a backing data list. When I'm doing dragging and dropping I want to find out where in the target list the new items should go to. I have broken the scenarios down into the following cases:...

How can I override TreeViewItem in WPF to allow asynchronous children loading?

I am using MVVM as my WPF architecture and I have a WPF TreeView implemented as delay loading (child items are not loaded recursively until you expand). However, I need to implement asynchronous loading as well upon expansion. Is there a way to do that? I need to keep this in control level and not in code-behind/application level. Than...

WPF Adjust Grid Height according to listview content

Hi to all, I have a listview with several rows, the problem is that even if the vertical scrollbar is visible, it doesnt work, I explain, it seems that because the grid height is Auto, then there is no maximum height and all the content is displayed, even if part of it is not visible, the only part-solution I've found is to set pixel he...

Bind Shape properties and attached properties to properties

I have a property: public double S { get; set; } and XAML: <Canvas Name="MainCanvas"> <Ellipse Canvas.Left="10" Canvas.Top="10" Height="10" Name="ellipse1" Stroke="Black" Width="10"/> </Canvas> How can I bind both Ellipse Width and Height properties and attached Canvas.Left and Top properties so that I can set values to be diff...

How to make editable WPF combobox which only allowed to enter displayed item list?

Hi All, I have one WPF editable combobox, but I only want user to allow to enter the text which is the start text of the displayed items in the combobox drop down list. For example, Combobox with the following items, Book Book2 Cat Tree User is only allowed to type B, Bo, Boo, Book, Book2, C, Ca, Cat, T, Tr, Tre, Tree. Thanks ...

Why do I get an IOException when I try to consume an image file that was added to the project as a link?

I have an IValueConverter in WPF that converts a relative file path to a BitmapImage. The Code: public class RelativeImagePathToImage : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var relativePath = (string)value; if (string.IsNullOrEmpty(relati...

Returning database view data using wcf service and binding results in WPF

Hello, Here's what I want to achieve: Have a wpf system tray application or a vista gadget that will show me live data from a database view. I need to use a WCF service to retrieve the data. The data in the underlying tables will be changing frequently but I can do without upto the second updates in the client (if I have to). How do y...

Pluralising and Localizing strings in C#

I've got a C# WPF application I'm attempting to globalize with resx files. It works splendidly. I've run into a hitch, however. I've got a relatively simple solution for pluralisation where I have a singular and plural form of the string I'm displaying and I pick one based on the number of whatever things I'm talking about. However, I'v...

Is "aim to develop WPF unless you need to drop back to Windows Forms" the general advice?

Is the general advice re windows apps technology to develop in "aim to develop WPF unless you need to drop back to Windows Forms". I known there are some specific pros/cons for particular scenarios/requirements (e.g. assumptions about what version of .net is available on the desktop) however I'm just after overall general advice. Li...

How do you validate a clr property after it has been updated instead of before when implementing IDataErrorInfo?

I have implemented IDataErrorInfo in one of my classes to validate a property of that class. The property is bound to a control on my wpf user control. The validataion works fine, except there is one vital flaw. It seems to be calling the IDataErrorInfo member public string this[string columnName] before the property is updated, so ...