wpf

How do I clear Command bindings registered by CommandManager?

I have this control (WPF) that uses a CommandBinding and it gets registered like this: CommandBinding binding = new CommandBinding(ApplicationCommands.Delete, OnDeleteExecuted, CanExecuteDelete); CommandManager.RegisterClassCommandBinding(typeof(MyObject), binding); So, when I unload the control, I want to clear this binding. How woul...

Observable collection with current item?

In a dialog from my application, I have an observable collection (stored somewhere else) bound to a list of tabs. When I close and reopen the dialog, the currently selected tab gets lost and winds up to the be the first one. How do I set up my tabs so that the selected tab persists? I had the impression that the observable collection ha...

WPF - ComboBox binding issue

Hi, I'm using WPF/MVVM and am having a binding issue with a ComboBox - any help appreciated! Heres my Combo ... <ComboBox Name="ComboBoxAvailableCriteria" Width="255" ItemsSource="{Binding AvailableCriteria}" DisplayMemberPath="SearchableAttribute.Name" /> And heres my ViewModel ... private List<SearchCriteria> _availableCriter...

Is it possible to "cancel" a dependency-property assignment from an IValueConverter, if there was no change in the property value?

I have a data-binding set on a dependency property of a class. I also have an IValueConverter to handle the calculation of this value based on other elements. The context of my question is inside the IValueConverter.Convert method. #1 If the calculated return value is equal to the current property value, can I tell the framework not t...

WPF How to create CUSTOM tunel routedevent?

I need a simple example of a Tunnel Routed Event tunnelling from a parent control to a child control. (THIS IS NOT REAL CODE) -- in fact, the deeper I go, the more I think that the XAML is wrong -- probably should NOT sign up for the tunnelled event in XAML on the child node (not sure?) <PARENT> <MyControl DoSomethingOnUserActio...

How to ensure that the top level WPF "Window" element handles TextInput RoutedEvents?

I've got an application that traps text entry at the window level (i'm using a barcode scanner) and occasionally the operator will click on view elements which then gain focus, taking focus off the window, and the window no longer recieves either previewtextentry or textentry events, any ideas? ...

Suggestions for WPF & WCF projects

Hi guys, I am trying to work on a home project so I can get some practice working on WPF & WCF applications. Can anyone give out suggestions on a sample WPF and or WCF applications that I can develop? Ideas are greatly appreciated. Thanks ...

Not receiving Drag events on an adorned element

I'm creating a drag and drop behavior, and the goal is to drag an item onto my grid, where a set of adorned elements representing the available actions will be available for the user to drop the element on. My problem is once I add the adorned element(s) to the AdornerLayer, I don't receive any Drag events. I need to get those events to ...

How do you create an off-center PerspectiveCamera in WPF?

I'm trying to more or less recreate Johnny Lee's Wii head tracking app, but using an augmented reality toolkit for the tracking, and WPF for graphics. To do this, I need to create a perspective camera using the top, bottom, right, and left parameters to create my viewing frustum, instead of field of view and aspect ratio (to those famili...

Testing Windows 7 multitouch on a dev machine without multitouch?

Is there a way to test the multitouch capability of an application using a non-multitouch enabled machine? I'd like to simulate user input for zoom, scaling and rotating during runtime. This is for a WPF application written in C#. ...

Image Flipping in WPF

How do you get an image to be reflected in wpf without using the xaml? I have a rectangle with a BitmapImageBrush as its fill. I want to be able to regularly flip this image (X-axis) back and forth at will in C#. I've read about using the ScaleTransform property but this only seems to work in the xaml and that's not what I want. This is...

How to bind a WPF control to the code behind?

I have this XAML: <Window x:Class="WpfBindToCodeBehind.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" Loaded="Window_Loaded"> <StackPanel Orientation="Vertical"> <Button Name="ToggleExpa...

WPF design question (custom control or mvvm)

Here is the scenario: I have a visual that displays some data The data to the visual can come in one of two ways Via user input through the keyboard or mouse Via some backend source Both these data inputs can be of one of two forms Control data or Raw data for simple display Control data causes changes in the visual Raw data is sim...

How can I get a control's DataContext from an external application using UI Automation (and/or White)

I'm using White to drive the UI of a WPF app, and it's worked well so far. I'm at the point however, where I need to poke into the internal state of the app under test to check some conditions. Specifically, I have a DataGrid (from the WPFToolkit), which is databound to a List<MyBusinessObject>. Each row therefore has a DataContext of ...

How do i get an Image for the various MessageBoxImage(s) or MessageBoxIcon(s)

How do i get an System.Drawing.Image for the various System.Windows.MessageBoxImage(s) and/or System.Windows.Forms.MessageBoxIcon(s) ...

Scope of View Models when using Service Locator Pattern in WPF app

Hi there, When using a Service Locator class to serve up ViewModels for your WPF pages to bind to. Should the ViewModels be Singleton scoped or Factory scoped? Is one generally a better idea for WPF applications?? I'm aware that in Silverlight, Singleton lends itself better to pages which are User Controls and are only moved into and o...

Fastest way to generate bitmap from polygons in .NET

After reading this blog, I want to try writing a similar program myself. One of the subtasks is to have a source set of polygons, and use these polygons to generate the bitmap that is going to be compared with the target image. In .NET 2005 the obvious method is to use GDI+. Simply create a bitmap, get a Graphics object that interfaces...

How to put a custom windows forms control in a WPF application?

As a short term solution I'm trying to jam a windows form 'usercontrol' into a WPF application. I see in the WPF application view that I can add a 'custom windows form control' to the project and it makes an empty custom control, but I can't figure out how to add it. Ideally I'd like to know how to take the .dll from my compiled window...

Can not perform this operation while a clock is assigned to the media player.

Hi Guys, I am Creating one MediaElement in WPF runtime and Saving it as XAML file. Now when I run this saved xaml I got this error message Can not perform this operation while a clock is assigned to the media player. After googling I found that due to SpeedRatio property in MediaElement this error comes. So how can I remove this prop...

WPF DataContext vs ItemsSource Performance

Hi! Suppose we have an ItemsControl, which is bounded to a source. Is there any performance difference between ItemsControl.DataContext = resultSet; and ItemsControl.ItemsSource = resultSet; (In both cases correctly binded in XAML) ...