wpf

Why does this code not bind SelectedItem to a property?

Hi, I'm pretty new to XAML, and my first task in a new job is to untangle a particularly malodorous collection of spaghetti code. Learning XAML at the same time as untangling this horror-show is proving somewhat beyond me, so my apologies for the homework-level questions I'm asking, these days. Anyway, I have the following XAML code: ...

Windows Form launched from WPF window showing no current system theme. Why?

Hi all. I have a WPF application that has a variable "x" which is an instance of a class from a custom C# assembly called "MyClasses.dll". This variable "x" has a method "LaunchForm" that launches a Windows Form "Form1" from another assembly "MyForms.dll". The form is launched as a dialog and shown in the screen but the current Windows X...

Theater Seating application in WPF -problems in databinding

Hello, I am new to WPF, and I want to develop an application for Theater seating in WPF- c#.net. I did some research but i am lost as i do not know how each seat's data (sold or not, price, in which row) should be eventually bound to field in a table in SQL Express. Should i be using ObservableCollection to populate the contents of a Dat...

WPF - keyboard behavior in Grouped ListBox vs. Grouped ComboBox

I Want My ComboBox to Behave like The standard ListBox When my data is grouped ListCollectionView and an Expander. I've Noticed that when I use the ListBox I can Move between the item groups and open\close the expandrs, but when I try to switch the ListBox to ComboBox, I get 'trapped' in the group i'm in - While using only the keyboard....

Class-level validation

Hello! I am validating a class with DataAnnotations utils. I have a class that has a Title property and an Item property. I want to apply a RequiredAttribute to the Title property but it should be invalid only if the Item property is null; if the Item property is set with an object, the Title is not required. In short words, I want th...

Right way to close WPF GUI application: GetCurrentProcess().Kill(), Environment.Exit(0) or this.Shutdown()

My GUI desktop-based WPF 4.0 (C# .Net 4.0) program works with SQL Server database. Each time when I run my application it creates connection to SQL Server via ADO.NET Entity Framework and if SQL Server is not reachable it throws exception and shows MessageBox with notification. Now I want that after user read this message application wi...

Wpf Mediaelement and .m4a files, SpeedRatio not working?

Hi, Im working with a simple mediaplayer based on this msdn example where the user can control volume, playback speed (SpeedRatio) and seek (position) using 3 sliders. Everything works correctly when I play .mp3 files, but as soon as I play an .m4a file the song playback speed, controlled by the MediaElement.SpeedRatio, is ignored. Vol...

Can I programmatically add a row to a WPF datagrid?

I just want to add a new row, I have my datasource in objects in which I need to do some processing. i need something like below for wpf datagrid... DataRow row = dataTable.NewRow(); foreach (NavItem item in record.Items) { row[item.FieldNo.ToString()] = item.RecordValue; } dataTable.Rows.Add(row); ...

Best way to do a boolean-or-to-visibility

I have a control that i want to be visible only if atleast one of a series of properties return true. I was about to implement my own BooleanOrToVisibilityMultiConverter, but it feels like there must be a better (and completely obvious) way to do this. Please enlighten me! ...

Finding a Visual beneath my own using WPF VisualTreeHelper advanced hit-testing

I have a seemingly simple task. Imagine a point, a visual tree and some Visual (point is within Visual). I want to use advanced hit-testing to get my hands on the first "leaf" Visual that is "behind" my own Visual. I have used VisualTreeHelper and its fancy hit-test methods but could not get the results I wanted. ...

Set Width of WPF DataGridCell individually for each cell?

Hello, I have a DataGrid with ONE column. The ItemsPanelTemplate of the DataGrid is in a WrapPanel so the rows are aligned horizontally. Each Cell of the "Row" has the same width, is it possible that every string in the cell takes only the space it needs so I have cells with a short/long width? ...

Want to find the control over which mouse is placed in wpf

i have a main control in wpf. and many controls placed in main control. when mouse moves over main control i want to find over which control in main control mouse is placed. ...

WPF 3D - mapping gradient brush on complex geometry

Hello, I wanted to ask if anyone knows how to map gradient brush on complex objects in WPF 3D. The result should look similar to 3D images in matlab (3D function for example). Lets say you have some 3-dimensional data you wish to visualize and you want to diferentiate certain levels of values by color. ...

WPF custom control looking weird on deployment

I use a custom numericUpDown control in my WPF application which works fine in my local development environment. However when i deploy my application the control looks strange, to be more specific, all the elements within the control seem to be in place but without the styles. What could be the reason for this? ...

BitmapSource.CopyPixels -what's a good value for stride?

I'm trying to get the pixel data from a WPF BitmapSource object. As I understand, this can be accomplished by calling its CopyPixels method. This method needs a stride parameter, which I don't know how to obtain. As far as I know, stride is value that's used when stepping in the array during reading or copying. What would be an appropria...

MVVM - WPF DataGrid - AutoGeneratingColumn Event

Hello all, I'm currently taking a good look at the excellent toolkit from Laurent and I have the following question. From Blend 4, I have added an EventTrigger for the Loaded event, in my ViewModel I have the following: public RelayCommand rcAutoGeneratingColumn { get; private set; } In the constructor I have: rcAutoGeneratingColum...

[WPF] Retrieve the End position of the Caret in the TextBox to put the Caret in the next TextBox

How do I find the end position of the Caret in a WPF textbox so I can`t move right anymore with the caret? ...

[WPF] How can I display multiple colored underlined Text in a Textbox

Hello, this code underlines all Text in the Textbox, can I underline only specific Text? Brush brush = Brushes.Blue; Pen pen = new Pen(brush,2); TextBox tb1 = new TextBox(); tb1.AcceptsReturn = true; tb1.Text = "This is a very long Text not?"; TextDecoration te...

[WPF] RichTextBox applies Bold when I continue writing

can I somehow stop this behaviour? ...

Is there a rich text editor control that does both spell AND grammar checking?

I'm looking for a winforms or wpf control that can do both spelling and grammar checking in english and also do red & green squiggly underlines, similar to MS Word. So far, all I've been able to find are spell-checker controls. I'd be open to good spell checking and grammar checking libraries as well - if you can recommend an integrati...