wpf

WPF C# Path: How to get from a string with Path Data to Geometry in Code (not in XAML)

I want to generate a WPF Path object in Code. In XAML I can do this: <Path Data="M 100,200 C 100,25 400,350 400,175 H 280"> How can I do the same in Code? Path path = new Path(); Path.Data = "foo"; //This won't accept a string as path data. Is there a class/Method available that converts the string with PathData to PathGeometry...

WPF Datagrid with some read-only rows

I have the need to show some of my WPF Datagrid rows as read only or not depending on a property on my bound model. How can this be done? ...

WindowsFormsHost Winform pdfviewer control problem

Hello, I have a wpf Usercontrol, inside i am using a Winforms pdfviewer to display pdf files. Also i have couple of Textboxes to enter document details. finally, A popup which display this user control. The problem is, when i try to type something in textboxes, ntn is happenning. when i right click on a textbox, i can see context menu...

How to bind WPF Datagrid itemssource to Collection of Collections ?

What is the best approach to bind a WPF DataGrid ItemsSource to an ObservableCollection of ObservableCollections ? e.g. public ObservableCollection<ObservableCollection<MyDataItem>> DataValues = new ObservableCollection<ObservableCollection<MyDataItem>>(); where MyDataItem may look like this: public class MyDataItem { public s...

WPF Converter casting causes Visual Studio designer exception

A converter such as what follows will cause the 2008 visual studio designer to not display the xaml, and error out with a "Specified cast is not valid." exception. public class ItemsVisibilityToGridColumnWidthConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo cult...

WPF treeview itemselected moves incorrectly when deleting an item

I have a treeview bound to an object tree. When I remove an object from the object tree, it is removed correctly from the tree view, but the treeview's default behaviour is to jump the selecteditem up to the deleted item's parent node. How can I change this so it jumps to the next item instead? EDIT: I updated my code with Aviad's sugg...

WPF Collections and Databinding

I am new to WPF and trying to wrap my head around WPF's framework, what it does and does not do for you. To clarify this, I would like to know what is the difference between this: public List<MyCustomObject> MyCustomObjects { get { return (List<MyCustomObject>)GetValue(MyCustomObjectsProperty); } set { SetValue(MyCustomObjectsP...

How do you bind Enter and Esc keys to OK and Cancel buttons respectively in a WPF dialog?

My WPF app uses a dialog with Ok and Cancel buttons. I would like to bind the Enter key to the Ok button and the Esc key to the Cancel button. Seems like it should be a simple thing to do. ...

WPF - Force ShowDialog to return

How can I force ShowDialog to return from a background thread? I have a WPF application built on top of a C++/CLR framework which is listening to messages sent by the framework. One particular message is so important that I need to close all the current windows. However, if a modal dialog (created by ShowDialog from my main window) is ...

Expression Blend problem

I'm using Expression Blend Preview for .NET 4 (WPF project). I set IsEnabled property to true, but when I compile project or run it button is always disabled. I do something wrong or it's bug in Blend? ...

Render a content control in another tab of TabControl

I have a program wherein there are multiple tabs added dynamically to a TabControl object programmatically. What I want to do is render the Content value of each of these tabs to a PNG. I am using a script I picked up elsewhere on StackOverflow or perhaps Google (lost the source). My code looks like this: if (tabPanel.Items.Count > 0) {...

How to reference right-clicked object in WPF Context Menu item click event handler?

In WPF application there is a Grid with a number of objects (they are derived from a custom control). I want to perform some actions on each of them using context menu: <Grid.ContextMenu> <ContextMenu> <MenuItem Name="EditStatusCm" Header="Change status" Click="EditStatusCm_Click"/> </ContextMenu> ...

WPF/Silverlight image/video playlist

Hi, I'm somewhat new to WPF/Silverlight so please excuse my ignorance if thw answer is blindingly obvious... I have the requirement to create a piece of software which gives the user the ability to schedule a playlist of images and videos (possibly flash content too but this isnt essential). I've had a look at various WPF/Silverlight ...

Unhandled Exception in XAML - How to solve ?

Hi, Please help me to understand the problem and solve this: Thanks ! ...

WPF - Can't display ObservableCollection in a window

I have an ObservableCollection that I can't seem to get to display in a window. Here is the code: The View Model: public class QueryParamsVM : DependencyObject { public string Query { get; set; } public QueryParamsVM() { Parameters = new ObservableCollection<StringPair>(); } public ObservableCollection<St...

How to Inherit a Control Template

I working on a WPF project where I've over-ridden the checkbox control for some special operations. That is working correctly. My problem is that the control template that was applied from the theme (shinyred.xaml from codeplex), is not applied to my over-ridden control. Is there a way to inherit the checkbox control template for use ...

Xamly begin a storyboard when a RoutedCommand is called?

Is there a way to begin a storyboard wen an ICommand is executed WITH XAML? ...

Drag & Drop Shapes on Canvas

Hi, I used MouseDragElementBehavior to let user drag & drop Shapes on a Canvas: MouseDragElementBehavior dragBehavior = new MouseDragElementBehavior(); dragBehavior.Attach(myShape); Now, I would like to know when myShape was moved and when myShape was dropped. Could you please suggest a code that prints the mouse coordinates when mySh...

Render bound wpf controls off screen to bitmap

I have a custom wpf control to do an arbitrary reverse image warp, that use a Viewport3D and custom matrix, and a mesh with an ImageBrush... I'm trying to render this to a bitmap entirely off screen. I am able to render a bitmap fine (I found to call .Measure() .Arrange(new Rectangle(...)) and .UpdateLayout()) before rendering, but the ...

WPF: Allow user to resize images in RichTextBox

Is there a method within the RichTextBox control in WPF to allow for the user to resize inserted images, or do you have to devise your own method for this. What I'm trying to achieve is shown below, a screenshot of a WordPad doing what I want: Notes: Reading the RTF file as plain text I find that the control tags related to image s...