wpf

Pattern / Methodology For Dynamic ContextMenu Based on Collection of Objects

Hello: Background I have a TreeView that follows the MVVM design pattern and supports multiple selection by recording TreeViewItem selections in a List. As it stands there are several types of TreeViewItems available for the user to select. They are: Two Root nodes of type WorldFolder and MyDataFodler which can contain child Folder...

Edit Validation.ErrorTemplate in code

I have a UserControl that contains a TextBox. The TextBox.Text property is data-bound and validated. When a Validation.Error occurs, I would like to edit the Validation.ErrorTemplate. Specifically, I would like adorn it with a Polyline. The end goal is to have a UserControl that has a red squiggly line under the text when it fails a va...

Find control position on canvas

I have a canvas which contains a few textblocks and I need to find the top, left corner points that I assigned them in xaml. How can I get those two properties? When I loop through the framework elements on the canvas I can't seem to find those to properties listed. ...

MessageBox-confirmation for critical operations

In my projects (WPF) I use System.Windows.MessageBox to show the user a confirmation dialog for operations that are critical, such as a delete-operation. My problem is that if I specify as button value MessageBoxButton.YesNo, the user cannot use the escape-key to cancel the operation. IMO this is one of the most annoying things, a progr...

Reuseable help Button and help popup

Hi, I have about 30 views and corresponding VMs in my application. I have a help button next to most user controls which gives some description of what the field is for. When the user clicks on that button, a popup opens and gives the description. What will be the best way to make this functionality reusable in all the views? I have cre...

Filtered WPF ListBox

I have written a small implementation to filter a listbox based on keyboard input. For an example if the listbox has values "Peter", "Ann" and "Andrew", typing character "A" will filter the list down to "Ann" and "Andrew". I have used the ICollectionView.Filter approach for filtering. However, now I need to highlight the matching charact...

ValidationRules on a ListView's bound items

My actual scenario is this: I have a ListView and a custom UserControl setup in a master-detail. It is possible, through a menu item, to add multiple items that are initially invalid. What I'd like to do is, eventually, prevent submission if any items in the list are invalid. Short term, I'm trying to give a visual clue to the item tha...

wpf resource dictionary organization - data context

The pre-release wpf ribbon control uses commands as resources, and the commands aren't dps so you can't bind directly to them. With an attached property and subclass of the RibbonCommand, as described here, I wound up with a pattern similar to this: // as resources <ab:CommandReference x:Key="AddCommandRef" Command="{Binding AddComma...

Making columns in a WPF ListBox

Hi, Problem: I have a set of items which have 3 elements: Image Description Numeric Value I want to display these in a ListBox (similar to the way Excel displays emails in the summary view) however, i do not know the width of the description field. If i dont set a hard coded value for the width in the ItemTemplate im using for the...

Updating WPF GUI from a DLL

This seems like it would be pretty common task, but I'm not having any luck searching for an answer. I have a WPF/C# application that relies heavily on a dll for database routines. I would like the dll to update some GUI elements, i.e. a progress bar. So far, it seems that the answer lies somewhere in System.ComponentModel and creating...

wpf - how do I apply same margins to all elements in a panel?

Is there a way of automatically tells all children items (e.g. labels, textboxes etc) to have a margin of 5, within a panel (e.g. dockpanel)? i.e. as opposed to having to set the margin for each element separately - also noting setting the margin on the panel itself is no good as then the panel has the margin not the elements. by the w...

How do I serialize a System.Windows.Media.Color object to an sRGB string?

I need to serialize a color used in a WPF application to a database. I'd like to use the sRGB values, because they're more familiar to those of us that have spent the last few years doing web development. How can a get an ARGB string (like #FFFFFFFF) from a System.Windows.Media.Color object? UPDATE: I was misled by the documentation on...

WPF ListBox Binding Performance issue

Hi, I have a listbox which has a datatemplate applied to the items. Each item id to display 3 text fields. The listbox is bound to an observablecollection. Everything is working fine, but when i try to load more than ~100 items into the collection, it starts chewing up all my CPU and takes ages to load. Any suggestions? ...

Is there any way we can Automatically Stretch Horizontally or Vertically Childrens in Canvas like Grid does?

Is there any way whether we can stretch Element placed inside a Convas if we give the Horizotal and Vertical Alignment properties to Stretch? ...

WPF app + PHP, fastest way of communicate data

Hello may be you can help me. I'm wondering about the fastest way to send and receive information between a WPF app (client) and a PHP (web hosting server). Is tcp with sockets the way to go? or it'll have problems with the firewalls and IT related stuff? Do you recommend me to go for a rest php version? Webservices? I would like to...

Desperately need help on Rx.Net

Hi guys i'm very very very new to Rx and trying to put together a simple test app. It basically subscribes to the window click event using Rx and sets the text on a textbox to "Clicked". It's a wpf app. Here's the xaml: <Window x:Class="Reactive.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...

[wpf] Error while increasing Opacity property using DoubleAnimation

Hi every body! I have a style for a ListViewItem control: <EventTrigger RoutedEvent="ListViewItem.MouseEnter"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="BitmapEffect.Opacity" ...

Button change sized using Mouse

Hi, I would like to know if there is a way to resize a button Width using the mouse, like when you are in the design mode, I'd like to change the cursor to the resize cursor when the mouse pass over the edge of the button, and with a sutained click resize the button. thanks !! ...

Several RadioButtons in a group unhandling event

Hi, If you have several radiobuttons in a group, and you have Checked event handlers in your code behind, if a radiobutton is checked how do you cancel this event handling so that the new radiobutton clicked does not get selected and your original checked button stays checked? The code in the event handler in the code behind distinguish...

RelativeSource FindAncestor without static resource in MVVM?

I'm new to WPF and the MVVM pattern so I have some problems with my bindings. In a details view of a customer, I want to list some statuses in a combobox. In my ViewModel the customer is at the root level, and so is the list of statuses. When using a static resource, I can use: ItemsSource="{Binding RelativeSource={RelativeSource Fi...