wpf

Is there a virtualizing WrapPanel for WPF available? Commercial or free ones.

Hi - Is there a virtualizing WrapPanel available? Commercial or free ones. I have seen some blogs (dan's included) but it does not seem to work well in my application, especially when i have child items of varying sizes. Also even with same size those free ones do not work well. Are there any commercial ones available in the market? I...

Adding new items to WPF Ribbon via Code

I'm using the WPF Office Ribbon, and I have a content view that I would like to have add new items to the ribbon when that view becomes active. I have code that adds a new RibbonCommand as well as a new RibbonButton to the group I want, but nothing happens when I add it. However, if I add a new group with the button, it comes up fine and...

What is the Windows Forms equivalent of the WPF's Keyboard class?

Question says it all - is there a class somewhere in Windows Forms that has the same functionality as the WPF System.Windows.Input.Keyboard? Or am I stuck always having to handle the keyboard events and keep my own state? (I'm specifically interested in a Forms analogue to IsKeyDown). Alternatively, is there a no-fuss way to use this ...

What is the best way to show an inherited object in wpf?

Lets say I have this: public class Result { public bool Success { get; set; } public string Description { get; set; } } Then I want to add another level, like this: public class AssertionFailedResult : Result { public string Expected { get; set; } public string Actual { get; set; } } In WPF, how would I show the simple r...

DataGrid: Help accessing a control defined in a CellEditingTemplate

Hello, I am using the WPF DataGrid with a DataGridTemplateColumn. The DataGridTemplateColumn.CellEditingTemplate contains a ComboBox with IsEditable set to 'true'. In my RowEditEnding event handler, I'd like to read the Text property of that ComboBox - the only problem is that I don't know how to retrieve the ComboBox instance within ...

How to hide and show content in wpf?

Lets say I have two containers: <StackPanel> <Label>First</Label> </StackPanel> <StackPanel> <Label>Second</Label> </StackPanel> And I'm bound to this object: public class Model { public bool ShowFirst { get; set; } public bool ShowSecond { get; set; } } How would I set the binding to show and hide the respective panels? ...

Catching Exceptions from WPF DocumentViewer

I am getting a PrintQueueException when my users are trying to Print a report that I constructed with a DocumentViewer control on a Window. I know why they getting the Exception, but I can't catch and handle the exception. Is there a way to handle the exception without deriving a new class from DocumentViewer? ...

How to find if object of a class exists.

Hi, On my ListBoxItem MouseEnter event I am creating a new window with the following code. Window w = new Window(); w.Show(); When the mouse leaves the current item I want to close the window. How do I do that? Many Thanks. ...

Sort WPF ListBox on button click?

First off let me just say I'm very new to coding so there are big gaps in my knowledge... anywho: Right, I'm trying to sort a WPF listbox when a button is clicked, preferrably in pure xaml (otherwise VB). I'm having a hard time seeing as most samples are written in C#. Here's my code: <Grid.Resources> <CollectionViewSource x:Key...

c# wpf overlapping controls not receiving mouse events

Hi, I am building a canvas control. This root canvas has several overlapping children (canvas as well). This is done so each child can handle its own drawing and I can then compose the final result with any combination of children to get the desired behavior. This is working very well as far as rendering is concerned. This does not work...

Binding StringFormat doesn't seem to work correctly

I have a DataGrid and an Expander like so: <StackPanel> <my:DataGrid Name="dataGrid1" AutoGenerateColumns="False" ItemsSource="{Binding}">...</my:DataGrid> <Expander Header="{Binding ElementName=dataGrid1, Path=SelectedItem.Name, StringFormat=Details of {0}}">...</Expander> </StackPanel> The binding is fine, but for some reason the s...

Use WPF object to 'punch' hole in another?

I've got an ellipse which is just a circle. My problem is I want to cut out a circle-shaped hole from the middle of the bigger circle and nothing seems to work. I've tried opacity masks and those did not work whatsoever. To further complicate things, the big circle has a DropShadowEffect. But because the circle is slightly transparent,...

Editable WPF ListBox

I have a ObservableCollection that's bound to a ListBox in WPF. I want the ListBox to be editable, and for the editing changes to be saved to the collection. Since WPF doesnt provide an editable listbox, I've tried creating my own by changing the ListBox.ItemTemplate. <ListBox.ItemTemplate> <DataTemplate> <TextBox Name="E...

What's the best method to switch between forms in C# ?

What's the best method to switch between forms in C# ? Scenario: I want to click a button in a Form1, kill the existing Form1 and create Form2. How can I achieve this ? I would much appreciate it, if someone could even compare the complexity of this task in Winforms vs WPF. ...

WPF - Pan & Zoom Image

I want to create a simple image viewer in WPF that will enable the user to: Pan (by mouse dragging the image). Zoom (with a slider). Show overlays (rectangle selection for example). Show original image (with scroll bars if needed). Can you explain how to do it? I didn't find a good sample on the web. Should I use ViewBox? Or ImageB...

How would I expand a Datagrid details section from a button click?

I'm trying to implement a datagrid that works like a folder tree (i.e. each row represents a folder and the details view is another datagrid showing files in the folder). I've tried to trim down my code for simplicity, so there could be mistakes, but here is my basic XAML layout: <my:DataGrid Name="dataGrid1" AutoGenerateColumns="False"...

Fast WPF Particle Background

Hello, I am building a WPF application and I want its background to be filled with particles with random: Opacity/z-order Size Velocity "Fuzziness" (blur effect) Directions (or path) I've found a really good example of what I'd like it to be, but unfortunately it's in Flash and it's not free... I've tried to implement it but I can'...

WPF: Canvas Z-Index Bug

So I made my own carousel control in WPF. I have stumbled upon a bug and was wondering if anyone knew how I could fix this like a method call or a series of methods calls or some work-around. Here is a print screen of my carousel: As you can CLEARLY see with this image, my mouse pointer is OVER the button with 16 written on it. But th...

What's a good guide to WPF Panels & layout in general?

Is there a good, concise guide to the various behaviors of the controls that inherit from System.Windows.Controls.Panel? Or just a WPF layout guide in general? In particular, I'm interested in how the panels handle child objects that have width or height set to "Auto" and Horizontal or Vertical Alignment set to "Stretch". Some layouts c...

WPF - Draw overlay on an image

I have an image that the user can zoom/scroll. I want to draw on a different layer some rectangles/circles (for example: drawing a circle for each person's face that was identified in the picture). The rectangle position is relative to the image. How do I create such an overlay? Thanks. ...