wpf

WPF keyboard navigation: How to expand a panel and put focus in the first control of that panel?

Kind of new to WPF and I am working on an app that has a general user input form and a "details" section that is hidden in an Expander. I am trying to get it so that if the user Tabs into the expander control it will automatically expand and put focus into the first control within that expander. Some stripped down XAML: <StackPanel> ...

WPF window accepts enter automatically!

I have an wpf application which has two windows "Window1" has a Button, on click which opens "Window2". "Window2" have some textbox which has been programmed to jump from one control to another on enter key press. TextBox1 is getting focus after "Window2" initialization. This application shows normal behavior when I click or use "Alt" ke...

Any suggestions for dealing with XpsDocument GetFixedDocumentSequence performance issues?

I'm trying to provide a live preview of XPS documents without hanging my UI thread. Opening the document is fast enough, but when I call GetFixedDocumentSequence(), my UI becomes unresponsive for several seconds while the document chugs away. // creating the doc is fine (0.005 seconds) XpsDocument doc=new XpsDocument("BigFile.xps",File...

WPF (.net 3.5) ValidationRule , IDataErrorInfo

I'm trying figure out the best way to validate user input and I've been looking at ValidationRule and IDataErrorInfo. I have a VM and a model and I want to ensure a user does not enter alpha char's into multiple textbox's bound to doubles (or ints). I'm running into 3 issues 1) When I use the ValidationRule the method returns a 'Valid...

Drag and Drop items from a WPF application onto Desktop

I have a WPF application containing set of UserControls. Requirement is that a user should be able to drag any of these UC's from application and drop it anywhere on screen(outside the main application window). From what I have learnt about D&D functionality in WPF , a drag source and drop target is must. But in the above case the drag ...

How to show different controls based on a condition in WPF?

I basically need a section of the screen to have an "authentication" box where, if you're logged in then it displays your user name and a "switch user" button, but if you're not logged in, it just displays a login button. I could have two completely different controls, put them both on the screen and bind their visibility property to Is...

Is there any .NET NAT Traversal open source app\tutorial?

Is there any NAT Traversal open source app\tutorial written in .Net C# using some open source lib\API or native .Net libs? ...

InvalidOperationException when assigning text to a TextField

I am having a weird problem with C#, I can't yet explain. I actually planned to create a simple file viewer that automatically updates the displayed text as soon as the file is changed, but it turns out more complicated than I thought. I have the following basic code: public partial class Main : Window { private FileSystemWatcher w...

Using commands to be notified that a collection has changed

Guys, I was wondering if there's any way i could handle when a collection changes and, after that, display a message to the user. As im using MVVM, i dont have any references to the model inside the view project, so i couldn't do MyCollection col = InstanceOfViewModel.Read(); Since View doesn't know anything about "MyCollection", a...

databinding to validation.haserror

I want to bind Validation.HasError to a boolean property on my viewmodel. I only want to know when there is a validation error so that I can disable my buttons on my VM using canexecute methods from my relay commands. I get this error though: 'Validation.HasError' property is read-only and cannot be set from markup. I have tried diff...

Binding 2 ComboBox to a Dictionary, then binding the ComboBoxes to each other

I have a Dictionary of int to char (decimal & ASCII character associated with that int). I want to have two editable combo boxes that are pre-populated with the initial values. If the user selected a value from ComboBox “A” (the dict key) I want the dict value to be populated in ComboBox “B” – and vice versa. It’s relatively easy to p...

How do you prevent adding duplicate values in a static ObservableCollection thread safe?

I'm not sure what to do as far as managing the _namePrefixes for this control. I know I can make it non-static, but it makes sense to be static to be consistent across all uses of this control in terms of content for my project. Also, I chose ObservableCollection because of the following scenario: I have 2 client machines, one for stand...

WPF datagrid selected row clicked event ?

Hi, I want to execute some code when a a selected row of the WPF DataGrid is double clicked. I know that the datagrid has a MouseDoubleClicked event and that it also has a row selected event but I don't see any event for "selected row double clicked" ... Do you think it's possible to capture this event somehow ? Regards, Seb ...

WPF troubleshooting: is there a way to see why binding fails?

so, i am trying to get the following to work: <Style x:Key="ToolTipVisibility" TargetType="{x:Type StackPanel}"> <Setter Property="Visibility" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},Path=EnabledToolTips}" /> calling this from inside of a xaml control, and the property is in my mai...

WPF/MVVM: Refactoring Code-Behind to make it ready for MVVM binding

Hello, I have this code in my code-behind file of my View: private string GetSelectedSchoolclassCode() { return ((SchoolclassCode)cboSchooclassCodeList.SelectedItem).SchoolclassCodeName; } private void dgTimeTable_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var columnNumber = dg...

How to prevent animating menus in WPF?

Our designer is going nuts about this and I just cannot find the right search keywords to figure out how to fix it. Menus and ContextMenus in WPF have "reveal" animations associated with them. We want to eliminate those without messing with system settings. I managed to pull the template out using Blend but there's nothing in there abou...

Referencing a value defined in xaml

Hi all. I have several controls which I would like to all share the same width, specified at compile time. So either they all use a width of 10, all use a width of 20, etc. What is the proper way to define this value once, and use it like a variable from there on out? "Gives you the idea" pseudocode: double my_width = 10; <Label wid...

How can I make a WPF window maximized on the screen with the mouse cursor?

According to the MSDN documentation for the WindowStartupLocation Property: Setting CenterScreen causes a window to be positioned in the center of the screen that contains the mouse cursor. Although the MSDN doc for the CenterScreen Field itself defines it somewhat less clearly as: The startup location of a window is the center...

Visual Studio 2008 - Can't edit events in WPF

I just got a new PC with Windows 7. While editing a WPF window, when I right-click on a control and select Properties, I get the familiar property window docked in the lower-right coner. For some reason, I do not see the lightning bolt button to toggle over to the events. Also, when I double-click on a control, nothing happens. Has a...

Update item in collection & display in WPF

I have the following scenario: User enters values in a form and submits The submit methods calls a service passing the form related object as a parameter The object is persisted in the db The object gets assigned a new ID and gets returned to the calling method The object is add to a collection in the submit method I have an expander...