wpf

ResourceDictionary element or UserControl?

I have some XAML to draw a logo and I want to re-use this in various other XAML files (it has no UI and requires no code). The top level of the logo XAML is a Canvas item. To use the logo in other XAML files is it best to define this logo as an element in a ResourceDictionary or create a UserControl? This seems easy with a UserControl...

3D Animation Rotating and Translating simultaneously in WPF

Hi, I have ModelVisual3D of a cube. I want to translate and rotate it at the same time. I wish the center of rotation to be in the middle of the cube(the cube rotates around its own axis). But when I try to do this applying both transformations the effect is not what you would expect. Since the object is translating the center of rotati...

WPF: Binding ContextMenu to visual parent

I know ContextMenus aren't part of the visual tree, but I've been trying to bind the Visibility property of a contextmenu to a property on it's parent UserControl. So far I've tried ancestor binding and experimented with a converted, but the only way that seems remotely feasible at the minute is to use a MultiValueConverter and reflectio...

WPF validation question : how to work with validation which involves 2 fields

Hello there, I have 2 textbox on the screen, one is 'from amount' the other 'to amount'. The validation rule is 'from amount' should be less than 'to amount'. Now my question is ,when user enters a pair of amounts in which 'from amount' is grater than 'to amount', how to make BOTH of the text boxes display with red border. And when u...

Problem with Binding Dependency Property on a UserControl

I have a two userControls (IconUserControl & DisplayUserControl), I'm having a problem with binding dependency properties, here's some detail: IconUserControl has a bool DP of IsDisplayShown DisplayUserControl has a bool DP of IsDisplayShown In the XAML I have: <local:DisplayUserControl x:Name="DisplayUserControl...

WPF Popup Control - Find X, Y Coordinates

I'm trying to get the X,Y coordinates of a popup control. I have tried: VisualTreeHelper.GetOffset(Popup); but the vector returned always contains (0,0) for X and Y. The parent of the popup is the layout root, which is a grid. The CustomPopupPlacementCallback also always returns 0,0 for it's Point parameter. The goal is to allow th...

How Can I Open a WPF Popup with a Delay?

I simply want to open up the WPF Popup with a delay, sort of like a ToolTip. How can I achieve this? And, by the way, Popup.PopupAnimation = PopupAnimation.Fade ... fades in too quickly. I want at least half a second in there. ...

WPF Reset Focus on Button Click

Hello, I have a Textbox and a Toolbar with a button. If I'm typing in the textbox and I Click the button I want the TextBox to lose focus so the binding gets updated. I don't want to add a UpdateSourceTrigger=PropertyChanged to my TextBox. But instead when I click on the button I reset focus to the main window so what ever I'm on loses f...

Deployment checklist

I am starting to deploy my desktop application. It is a syntax highlighting notepad. I am considering deploying it on the web. What is like a list of things that I should do before I deploy my application? ...

Drag'n'drop files from (e.g.) iPhone in Windows Explorer onto a WPF application

I have a C# WPF app that allows users to import files by dragging them in from Windows Explorer and dropping them on the main app window. It works fine when dragging files from physical disks, but when dragging files from a connected device like an iPhone or camera connected via USB, I don't recognise any of the data formats returned by...

WPF drawing performance with large numbers of elements

I'm trying to create a custom control in WPF to display the game tree for a game of go (see here for what it looks like). I've more-or-less got it working laying out the nodes, but one problem I've found is that it begins gets noticeably slow to render/navigate (it's in a scroll viewer) when the number of nodes gets larger than about 30....

WPF Datagrid Multiple Selection without CTRL or Space

The WPF Datagrid has two selection modes, Single or Extended. The WPF ListView has a third - Multiple. This mode allows you to click and select multiple rows without CTRL or Shift being held down. Anyone know how to do this for the datagrid? ...

Xceed WPF Datagrid Printing fixed column on every page

I have a grid with one fixed column and many other columns. When i do a print (datagrid.Print()) on the second page i have the columns that would not fit onto the first page but without the fixed column (which is only printed on the first). I would like to repeat the fixed column on every page i print as it is the key to the data. Is thi...

"Invalid Window Handle" on exiting of WPF application that uses System.AddIn

I am working on a WPF application that is using System.AddIn to solve a memory leak issue we were having with a Windows Forms based control that was wrapped in a WindowsFormsHost control. The add-in is used to load and unload the Windows Forms based control as need to avoid the overhead of the WindowsFormsHost, which will hang around unt...

Is it possible to view effects of data triggers in design in Expression Blend 3?

Blend supports displaying the graphical representation of a style resource, and allows you to select an active property/event trigger to view or modify. However, it's a common occurrence to have visual elements controlled by DataTriggers. Is it possible to tell the designer that it should consider a DataTrigger 'active' so that its visua...

How can I create a WPF style so all Image controls have a MouseDown(click) event on it?

Since the Image control doesn't have a Click event, I simulate it using MouseDown event and it works exactly like a Click. Here's my style: <Window.Resources> <Style x:Key="imageStyle" TargetType="{x:Type Image}"> <Setter Property="RenderTransform"> <Setter.Value> <ScaleTransform /> ...

Combo box styling to show rating and description WPF

Hi all, I'm not very good with styling in WPF, so I thought that I would ask here and see if anyone can help. I have a combo box which is bound to a view model that has a rating and description, when I hover my mouse over a item the item changes to show the rating and description for that item. This works ok however because some of th...

WPF Treeview, SelectedItem moves incorrectly, why doesn't this work??

I have a WPF treeview that is bound to an object tree. When I remove an item from the tree, the TreeView SelectedItem jumps to the parent node of the item that was deleted. I am trying to fix this problem and have tried a bunch of different things, including inheriting from the TreeView and TreeviewItem and overriding the OnItemsChanged ...

WPF vs Windows Forms in desktop applications

Hi, I've been developing C# Windows Forms applications for a couple of years and while I've heard and read about WPF I've never really come in close contact to it. With some time to spare this spring I though I'd give it a go though, but first it'd be intresting to know what you guys thought about it. What do you think, is it worth the ...

How to change ListBox DataTemplate in WPF based on CheckBox

I am trying to apply a DataTrigger to change the DataTemplate for a listbox and am getting the error "Error 1 Cannot find the Trigger target 'IssueListBox'. (The target must appear before any Setters, Triggers, or Conditions that use it.)" I have a Listbox in my Main Window (In a DockPanel along with other Controls): <ListBox x:Name...