wpf

DelegateCommand vs RoutedCommand and gestures - WPF

Hi, is there anyway for DelegateCommand's to support gestures when building a composite WPF app? I'm trying to create a command used by a MenuItem and also a Button, which can be accessed through a keyboard shortcut, but which sits inside a class in a separate assembly. I can use a RoutedCommand, but I want to minimise any code-behind....

Windows 7 Animation mouse drag event

Is there a way to have custom animation replace the defauly windows animation when you drag a window to the edge of the screen? ...

WPF Non-Nullable Databinding to default a cleared TextBox?

I have a WPF Textbox, with the Text property bound to an int value (non nullable). When the form loads, the text box has a 0 in it. Is there any way to make this textbox default to empty? I was setting the value to null in the code behind when the form loads, but it seems that in places, this is throwing errors that are being hidden t...

WPF: System.InvalidOperationException and System.Reflection.TargetInvocationException occasionally happening.

When running my program, sometimes I get these exceptions, other times I don't. This is the flow of execution: User clicks a button in the Window1 class. Class collects inputs, backgroundWorker.RunWorkerAsync() is started. In the DoWork, App.doStuff() is called. Inside App.doStuff(), I create another thread to show a progressbar in a di...

How can I make a control lose focus if the user clicks on something that's not focusable?

I've got an ItemsControl filled with dozens of items; each item is a bound text box and a couple of buttons. Because I want the user to be able to tab from text box to text box, the buttons have Focusable set to False. This works just fine. The only problem is that since the text boxes aren't losing focus, their binding isn't updating...

WPF TreeView HierarchicalDataTemplate - binding to object with different child collections

I am trying to bind a collection to wpf TreeView control using data templates. Each item(Person) in the collection also contains two different collections(Cars, Books) of type car and book. Here's simplified list of the objects involved to save space. public class Person { public string Name public List<Book> Books; public List<C...

what causes the .NET SerialPort class DataReceived event to fire?

I understand from the MSDN docs that the event DataReceived will not necessarily fire once per byte. But does anyone know what exactly is the mechanism that causes the event to fire? Does the receipt of each byte restart a timer that has to reach, say 10 ms between bytes, before the event fires? I ask because I'm trying to write a...

WPF binding set before application starts does not notify?

In theory this code should provide me with a 300x300 window with a blue background from having the window's content bound to an object of type AstRootViewModel, however this doesn't seem to be the case. I'm wondering it this is happening because I don't call astApplication.Run() until after I set the mainWindow.ViewModel property. Usin...

Having an issue with my TextBox control template

I am working on a simple textBox template, which is just two borders, one with a gradient background. Now, my specific issue is that I want to be able to set the foreground color of the textBox to whatever color I want and have it work correctly. However, I can't seem to get both the disabled foreground and enabled foreground colors to...

WPF Binding issue (UNIQUE CONSTRAINT violation on UPDATE) how to reject changes?

ok please be gentle, I am new to WPF and LINQ - I have a strange problem here. I have a search screen and an add/edit screen. I have the add/edit screen bound to a 'CompanyContact' object and a search screen bound to a collection (CompanyContacts). I have a 3 column unique constraint (FirstName, LastName, CompanyId) on the CompanyConta...

Store array in SQL Server 2008

I am developing a contact manager application using SQL Server 2008 (service-based database) . Most contacts have several emails or several phone numbers. So is there a way to store an array as a datatype in SQL Server? Or does anyone have an alternative to this way? ...

WPF: Is there a way to save the image in the Viewport3D?

I have some 3d points I have to plot and since as far as I know there isn't a chart library for C# that will do this easily, I thought the next easier way to do it would be to create the points in a viewport3d and save the image. ...

What are the differences between the WPF designer in Expression Blend and in Visual Studio (2008)?

This was inspired by a question I asked recently regarding design time behaviour in my WPF app. (http://stackoverflow.com/questions/2290499/cant-databind-at-design-time-in-wpf-using-mvvm-viewmodel-property-never-gets-c) The net result of that is that my design time DataContext/ViewModel works perfectly in Blend, but doesn't show up in V...

Best practices for sharing a property among items of an items control

Lets say I have an ItemsControl in a Canvas. Each Item will have its own position, but I want all items to share that same width. So if the user changes it in one place, all items get updated. What is the cleanest way to do this? Right now I see 2 solutions. Whenever the settings change, I update the width property for each item. Th...

WPF Designer - Update attached property when control is added/dragged

I have made a custom panel which has attached properties for each childs position (Left, Top). When I drag a control from the toolbox onto my custom panel, it draws at 0,0 as these are the default values for the attached properties. If I try and move the control around the panel it just stays at 0,0 as moving in the designer does not upd...

How to handle exceptions from a BackgroundWorker thread?

In a WPF app I have a sheduled database access task, periodically run by a timer and this task have been executed in a BackgroundWorker thread. When connection attempt failed I raise an exception by try_catch construction and I want to update a Status Bar text in a UI thread. Is there some prebuild event construction in a BackgroundWo...

Datagrid (editable issue, access issue) in WPF

I created a Datagrid, as shown in this figure --> http://img682.imageshack.us/img682/5109/datagrid.png where user is supposed to enter data. In one of columns, I added Combobox.Now, the Datagrid won't allow me to enter data in the cells. IsReadOnly="False" was also not working, it was giving some "EditMode exception". So, what I did wa...

WPF data bound ListView/ListVBox won't select if list only has one item

So this is pretty mystifying. I have a databound ListBox (or ListView, it happens with both), and if it has more than 2 items in it, selection works - I get a blue highlight bar and the item looks selected. If I only have 1 item, the selection does not work - I do not get a blue highlight bar, but the selection events all fire as normal....

Smooth scrolling for WPF DataGrid

Hi, I am using WPF datagrid, only modification I have in place is: <toolkit:DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="TextWrapping" Value="Wrap"/> </Style> </toolkit:DataGridTextColumn.ElementStyle> I have this modification so if the cell contents are longer, they str...

Use a Regex to form delimited string for SQL Server

I have a SQL Server database (service-based) with a table (Contact). Instead of having multiple tables, I decided to have one delimited string called Emails. So how could I use a Regex and a delimiter to add on to the string. ...