wpf

How can I get IntelliSense to auto-complete an enum on a custom/user control in XAML?

In XAML if I am defining the Orientation property for a StackPanel, IntelliSense brings up the Orientation enum. If I'm defining my own control with a DependencyProperty based on an enum, is there a way to get IntelliSense to bring up the enum? Enum: public enum MyEnum { Foo, Bar } DependencyProperty in control: public static reado...

C# - Templated Printing from Object(s)

I'm in need of a solution to print or export (pdf/doc) from C#. I want to be able to design a template with place holders, bind an object (or xml) to this template, and get out a finished document. I'm not really sure if this is a reporting solution or not. I also don't want to have to roll my own printing / graphics code -- I'd like ...

How to build the ViewModel in MVVM not to violate the Single Responsibility Principle?

Robert Martin says: "There should never be more than one reason for a class to change". Let's consider the ViewModel class which is bound to a View. It is possible (or even probable) that the ViewModel consists of properties that are not really related to each other. For small views the ViewModel may be quite coherent, but while the appl...

Is there a "preprocessor" symbol corresponding to the /unsafe flag?

I'm dealing with a WriteableBitmap in C#. I'm currently using an unsafe code block to directly access the pixels via WriteableBitmap.BackBuffer. I'd rather depend on the /unsafe option, however, so I'm considering using WriteableBitmap.WritePixels instead. Is there some way of conditionally compiling in the "unsafe" version such that ...

Looking for DependencyProperty.Register shortcut.

Defining WPF properties is too long: public static readonly DependencyProperty FooProperty = DependencyProperty.Register("Foo", typeof(string), typeof(FooClass), new PropertyMetadata("Foooooo")); I have a helper method, making it a bit shorter: public static readonly DependencyProperty FooProperty = WpfUtils.Property<string, Foo...

In my WPF project installer, how do I bundle the .NET3.5 installer?

I developed some WPF projects, but I met a very serious issue. As you know, the .Net 3.5 installation is a pain (huge and relying on internet access). This is a problem on when we ship my product. Is there a way to bundle the redistribution part only? ...

WPF: Collision Detection with Rotated Squares

With reference to this programming game I am currently building. Thanks to the answers from this post, I am now able to find the x-y coordinates of all the points of the rectangles (even when rotated), and Collision-Detection with Walls is almost working perfectly now. Now I need to implement collision detection with the bots themselve...

OneWay binding stops working after the target manually updated

I have such WPF binding code: TestModel source = new TestModel(); TestModel target = new TestModel(); Bind(source, target, BindingMode.OneWay); source.Attribute = "1"; AssertAreEqual(target.Attribute, "1"); target.Attribute = "foo"; source.Attribute = "2"; AssertAreEqual(target.Attribute, "2"); The second assertion fails! This see...

Definitive source(s) for the difference between Silverlight and WPF

Does anyone know of a definitive guide or guides that tells us the differences between WPF and Silverlight. I know that Silverlight, for example, doesn’t have all the controls and all the namespaces that WPF has. Is there a source which tells me exactly what controls and namespaces are absent in Silverlight? There are other things th...

WPF Image Load to Display Delay

There is a slight delay from setting the Source of the image control to the actual displaying. I need some way to find out when exactly the Image is displayed but I can't seem to find any events that I can hook into. Does anybody have a way to detect this? ...

WPF - How to implement INotifyPropertyChanged when Properties are dynamic

I have a business object that implements a collection of PropertyObjects. BusinessObject SomeCollection Property1Object (Name=Height) Property2Object (Name=Width) Currently, I am setting the DataContext of UserControl to be the BusinessObject. I've found that I CAN reference into the collection in the binding with s...

WPF - Get airport display type transition when data changes

A client has asked for a display to flick over like an airport display screen, ie each row flicks over when information changes. I am not sure which is the best control to use, or the method of getting each row to transform one after the other. any suggestions woul b gratfully accepted John ...

Dynamic UI vs Static UI

I've been wondering, at what point should I give up the convenience of a static data entry form with designer support for a dynamic UI which removes a lot of code duplication? There seems to be a conflict in the programming world where people constantly try to remove code repetition to improve maintainability and yet when it comes to fo...

using OpenFileDialog for directory, not FolderBrowserDialog

I want to have a Folder browser in my application, but I don't want to use the FolderBrowserDialog. (For several reasons, such as it's painful to use) I want to use the standard OpenFileDialog, but modified for the directories. As an example, µTorrent has a nice implementation of it (Preferences/Directories/Put new downloads in:). ...

How can I bind to an enum in WPF with a "current" value

I have a simple .Net enum. I also have a view model object which has a "CurrentValue" property of the type of my enum. This property can be data-bound (the object implements INotifyPropertyChanged). Now I'd like to show one UI element for each value of the enum, in a specific order, and have the "CurrentValue" highlighted (bold). I would...

Custom Command WPF

I have an application that contains Menu and sub menus. I have attached Appliocation Commands to some of the sub menu items such as Cut, Copy and Paste. I also have some other menu items that do not have application commands. How could I add a custom command binding to those sub menu items? I have gone through this artcile but unable to ...

STArtThread

HI All i'm completing a sample Project(WPF) to show my boss but i need a feature to finish it. I have a Login Window to authenticate and access in the software now i wish put this LoginWindow as STArtThread so if the user can authenticate(with right password and username) automatically the LoginWindow disappear and can access to use the...

Print FixedDocument programmatically

Hi I am using a WPF FixedDocument with databinding for a simple invoice report. Works perfect when viewed inside the sofware itsself. But i want to print a series of invoices in one click. The following code works perfect (quick 'n dirty, just loads an invoice one by one directly inside the viewmodel, for testing purposes) when I choo...

Absolute positioning in WPF

I have a long text and show first sentence in a TextBlock. I wish by clicking the TextBlock or a button to show a panel below the TextBlock with full text. I wish this panel be absolutely positioned and be displayed above any other elements, you can do a similar thing in HTML showing and hiding absolutely positioned 'div' element. How t...

multiple userControl instances in tabControl

I have a tabControl that is bound to an observable collection. In the headerTemplate, I would like to bind to a string property, and in the contentTemplate I have placed a user-control. Here's the code for the MainWindow.xaml: <Grid> <Grid.Resources> <DataTemplate x:Key="contentTemplate"> <local...