wpf

How to create custom pair of event/preview event?

I mean if i have some custom event with bubbling strategy, then who must declare preview event and who must care about its raising? Me or WPF? for example I has class with event public class WindowControl : ContentControl { public static readonly RoutedEvent StateChangedEvent; static WindowControl() { WindowControl.StateChangedEvent ...

WPF - what is the best way to implement a panel that hides?

I have a main application window that also implements a dock panel. At the bottom of one of the existing dock panels, I want to add a window that the user can hide or view at will. What's the best way to implement this? I can envision most of the code behind this, I just need to figure out the appropriate control for this window to appea...

Ctrl key press condition in WPF MouseLeftButtonDown event-handler

How I can add additional condition of certain keyboard key, say, Ctrl-key state to WPF MouseLeftButtonDown event-handler? private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ... } ...

Popups in WPF immediately lose focus and close

Hello, I've been beating my head against a WPF Popup issue, and am hoping someone can help me:) The outline goes like this: Our app stores a list of UIObjects - these represent elements that are displayed in a viewport 3d (via a member UIRenderObject, which is just a flat, square mesh with a bitmap on it) and in a treeview (via a membe...

Update binding of TreeViewItem using code? (XAML / WPF)

Hey I have a TreeView whose ItemsSource is set to a Model I have. 3 levels deep is an object whose state can change and, rather than write a View and ViewModel for each stage (very lengthy business) I wanted to just update this using code. So basically I have an event that is fired once my model updates, I catch it then find the TreeV...

Using M-V-VM with WPF, how do I instantiate a Dialog View given a ViewModel?

I'm using M-V-VM with dialog boxes. The process I'm using for creating dialogs is as follows: A ViewModel command wishes to open a dialog. It creates the ViewModel for the dialog (we'll call it DialogViewModel). It then passes the ViewModel off to a DialogProvider to create the actual View. This makes my dialog boxes testable, as the...

Sortable combo box with columns

Hi, I have a combo with more than one value in it (different bindings from the same source) I would like to create a combo box where the user could sort by those columns and also include a header to clarify the informations Example : Item No | Name | Rank 00 | foo | 0 01 | bar | 2 02 | too | 1 We could sort by Item ...

WPF - Workaround for ValidationRule not being a DependencyObject

What is the best solution for not being able to use data binding on a ValidationRule property since ValiationRule is not a DependencyObject? Below is an example of what I would like to do. I want to be able to validate the text in the TextBox against some other DependencyProperty. <TextBox Name="myTextBox"> <TextBox.Text> <...

How to update GUI with backgroundworker?

I have spent the whole day trying to make my application use threads but with no luck. I have read much documentation about it and I still get lots of errors, so I hope you can help me. I have one big time consuming method which calls the database and updates the GUI. This has to happen all the time(or about every 30 seconds). public c...

Specifying and displaying columns of a DataGrid in WPF declaratively using a binding?

Is there a way to specify DataGrid columns declaratively using a binding? (And to set the columns' properties using this binding?) Idealy, I would have a list of objects (e.g. rows) databound to the ItemsSource and one of their properties would be a dictionary (or a list of objects of a certain class or whatever) with a name and a value....

Using ItemsControl on a multi-leveled TreeView

My co-worker threatened to put me on TheDailyWTF today because of my property I wrote to be used to build a 3-tiered treeview with ItemsControl. I bear you the footprint: ObservableCollection<KeyValuePair<string, ObservableCollection<KeyValuePair<string, ObservableCollection<MyType>>>>>; My goal was to create an ItemsControl that wou...

How to bind WPF Datagrid to a joined table

Hello, I have a big problem. I try to bind my WPF Datagrid to a table, created with inner join. I have created a class for the info to convert successfully: public class NeshtoSi { public NeshtoSi() { } public string ssn; public string name; public string surname; } And then I create t...

How to unanimate WPF DependencyProperty?

After running WPF animations on dependency properties in code behind, the dependency properties can no longer be set using SetValue. They can only be changed through animations. I want to change a dependency property, some times through short animations, sometimes immediately in code. So how can I remove the animation from a dependency...

Is it possible to capture any unspecific input event in C#?

I want my application to be able to display certain information when no user input has been detected for some time (like a Welcome/Instruction layer). Is there anyway to have the application register any form of user input (keyboard, mousedown/move etc) without having to write handlers for each of those events? Is there a generic input ...

wpf user control RadioButton preselection

Hi I got a very simple user control (visifire charts + datepickers and some radiobuttons to control filtering etc) <GroupBox Header="Scale" Width="159" HorizontalAlignment="Left" Margin="10,47,0,0" Height="38" VerticalAlignment="Top" Name="scalingBox"> <Canvas Height="16"> <RadioButton Name="scaleDays" Content="Days" GroupName="g2...

C# WPF DataGrid outside Window

I am building an application that requires a Datagrid that can be hidden. I have tried wrapping it in an Expander but it isn't exactly ideal. Ideally what I would like is the ability to have the DataGrid "floating" outside the main window without affecting the other controls and just having a button to hide and show it when needed. Is t...

WPF - How to set DataContext on virtual branch of logical tree?

How do I set the DataContext of "myElement" to the same DataContext as the user control in XAML? I have been able to do it in code-behind via myElement.DataContext = this.DataContext in the UserControl constructor, but I'm trying to understand how to do the same thing in XAML. This is related to creating virtual branches to the logical ...

How do I add a delay after a count down timer

I am using a DispatchTimer to perform a count down before triggering the release on a camera. The UpdateCountdown method is used to change the image displayed to the user before the camera fires. Rather than having the TakePicture method execute immediately, I would like have a slight delay after the counter reaches zero and the last i...

WPF - Why isn't ValidationRule a DependencyObject?

Is there a technical reason why ValidationRule is not a DependencyObject? ...

TabControl.Orientation?

I wanna set a TabControl that its header are in the left side instead of on top, how do I do that? ...