wpf

XpsDocumentWriter.WriteAsync not working

I am trying to use XpsDocumentWriter.WriteAsync to write to a printer. Write works perfectly but as soon as i use WriteAsync nothing happens. Do i need to do anything special to use WriteAsync ? ...

Grids with ViewModels - WPF

Sorry if this has already been asked, but I just want to make sure that I'm doing this right. If I have a domian object that has say 10 properties on it. I have a grid on my main form that I want to show the pretty much all the the properties from the model. I created a viewmodel to wrap the domain object to show in the gridview but t...

WPF: DependencyProperty refusing to work.

I'm trying to register 3 dependency properties on a Window to control it's formatting. I've looked over and over the code but I must be missing something. public static readonly DependencyProperty TextColorProperty = DependencyProperty.Register("TextColor", typeof(Color), typeof(WinStickyFingers), new PropertyMetadata(Colors.White)); pu...

WPF/C# - test connection string and fail elegantly

I've got a WPF application that uses LINQ to SQL DataContexts. What's a "best practice" way of testing the database connection and letting the user know that the connection is either bad or the network is down, etc, so that the app doesn't just bomb. Right now, I get the Splash Screen and then a "Program has stopped working" while "Win...

Basic Layout problems with WPF ListView

I have a simple List View: <ListView Name="Container" > </ListView> 1) I'd like items to be listed vertically till there's space and then to fill another column (header not needed): 147 258 369 I am adding items programmatically like this - but they display horizontally and then go onto the next row when space runs out: foreach (...

is there a good alternative to richtextbox in wpf?

Hey all Blend seems to crash when I try to edit the template of a RichTextBox (even blend 3.) I need an alternative that can display bold, highlighted, italic text of different colors etc. Is there anything like this? ...

Use another control as an opacity mask in WPF?

Hi. I'm trying to use the OpacityMask property combined with a VisualBrush so that when you drag an image over another control (such as another image, rectangle, or any other control), the part of the image that is over the second control has a different opacity. That is, the image has some non-zero base opacity, and any part of the im...

Unknown assembly with random name loaded by WPF application

I have a WPF application and I notice that when I run it there's a line in Visual Studio's output window which says 'SomeApp.exe' (Managed): Loaded 'lwrpft7j' The name is different every time. It is listed when I call AppDomain.CurrentDomain.GetAssemblies() as well. What is this random assembly? ...

WPF - is it possible to change the opacity of a GridColumn?

I want to have a grid of values with the headers in the left column and the databound results in the right column. When the values change, I want them to fade in. Is it possible to animate the Opacity of the right Column? Or would I have to animated the Opacity of each separate TextBlock that's in each row of the right column? ...

What causes a Value Converter to fire?

I am setting an IsEnabled property of a control based on whether or not a SelectedIndex >= 0 in a ListBox. I can do this in the code behind, but I wanted to create a value converter for this behavior since it is something I do frequently. I created this Value Converter to handle the task and bound it to the IsEnabled property: [Va...

Is xaml in WPF equivalent of .Designer.cs in Windows Forms apps?

Is xaml in WPF equivalent of .Designer.cs in Windows Forms apps? Does it just provide compile-time state for the UI? I am not sure but it looks like you can do things programmatically with xaml at run-time. If I have a basic UI state where everything is added at run-time, then should I be looking outside the xaml stuff? ...

saving WPF InkCanvas to a JPG - image is getting cropped

I have a WPF InkCanvas control I'm using to capture a signature in my application. The control looks like this - it's 700x300 However, when I save it as a JPG, the resulting image looks like this, also 700x300 The code I'm using to save sigPath = System.IO.Path.GetTempFileName(); MemoryStream ms = new Mem...

WPF: How do I bind the color property of a gradientstop that is located in a controlTemplate in vb code?

I need to do this in order to create a dynamic background brush for a custom control (inherits ContentControl). My custom control has two dependency properties: StartColor and EndColor. In the control template for the custom control, the control is wrapped in a border that's background is a RadialGradientBrush with gradient stops. one gr...

Multiple Storyboards or Animations that share the same timeline?

I have a a bunch of WPF UserControls that internally trigger some animations upon user interactions. All animations have repeatbehavior = "true" and all animations have the same duration. Now I would like synchronize all those animations on one timeline so they are fading in and out in sync. No matter when the user triggerd the animation...

How to best represent selectable items in a collection within the M-V-VM design pattern?

I'm just beginning to explore the M-V-VM design pattern while redeveloping an application and I'm running across a consistent theme where I have collections that I need my ViewModel to expose to the View which contain items which are to be selected by the user. Please note that when I say "selected" what I mean is that they are chosen in...

Pattern for "unavailable" value when databinding in WPF

What is the typical pattern for displaying an "unavailable" value when databinding in WPF? For example I am using MVVM, and TextBlocks in my view are bound to my viewmodel's properties, some of which are ints. There are times when I want to temporarily display two dashes ("--") in my view rather than the property value. I could change ...

WPF -- trap database connection errors from ObjectDataProvider

I've got a WPF application that uses LINQ to SQL DataContexts. The first call to the database would be from the ObjectDataProvider in the XAML of the main form: <ObjectDataProvider x:Key="WaitingPatientDS" ObjectType="{x:Type local:clsPatients}"> <ObjectDataProvider.ConstructorParameters> <sys:Boolean>True</sys:Boolean> ...

WPF Launch Browser with Credentials

I'm using WPF and C#. I want to be able to launch a browser window, most likely IE, and provide known credentials so that the Windows-based application can handle the transition from itself to an outside browser without having the user enter his/her credentials again. I do know how to launch the browser: System.Diagnostics.Process.Sta...

WPF TreeView doesn't show content

I have a WPF application that includes a TreeView. The user adds content to the tree using right click and context menu. This creates a new TreeViewItem that is added to the tree's ItemCollection. The problem is that sometimes the new items are not shown, although they were added. If you minimize/maximize the window they suddenly appear...

Serializing Shape objects in WPF

Hi, Does anyone know a good way to serialize a System.Windows.Shape (incl. Polygon, Circle, Triangle etc.) object so that it may be saved in a database? I have tried to serialize it using BinaryFormatter but it throws an exception saying that it is not marked as serializable. Thanks in advance for any help. Cheers, Nilu ...