background preloader

WPF

Facebook Twitter

Muhammad Shujaat Siddiqi: WPF - Binding Converter Parameter [Including Discussion about Binding Reflector] In this post we will be discussing how we can bind ConverterParameter used in WPF Binding.

Muhammad Shujaat Siddiqi: WPF - Binding Converter Parameter [Including Discussion about Binding Reflector]

As we know that ConverterParameter is not a DependencyProperty, we can not bind it directly. We will be looking at the possible workarounds to achieve the similar results. As always, we will start with a simple window and then add necessary ingredients for this discussion. Let us create a sample Window with two text boxes for entering Gender and Name of a Student. As you can see that we have used an instance of MainWindowViewModel as DataContext of the Window. Namespace WpfApplication_ConverterParameterBinding{ using System.Windows; class MainWindowViewModel : DependencyObject { public static DependencyProperty GenderProperty = DependencyProperty.Register("Gender", typeof(string), typeof(MainWindowViewModel), new FrameworkPropertyMetadata() { AffectsRender = true }); public string Gender { get { return (string)GetValue(GenderProperty); } set { SetValue(GenderProperty, value); } } string salutation;

MVVM Light: MessengerEl Blog de Fox. Y aquí estamos con la tercera parte de este artículo sobre MVVM Light.

MVVM Light: MessengerEl Blog de Fox

En esta ocasión hablaremos sobre Messenger y no, no es el que usas para chatear con tus colegas, aunque la idea es parecida. Antes de explicar en qué consiste lo de Messenger vamos a presentar al concursante el ejemplo. El ejemplo es parecido al del anterior artículo, pero le hemos añadido una vuelta de tuerca más para mostraros otros conceptos nuevos. El ejemplo se mantiene simple para no liaros con cosas que no tienen que ver con lo que vamos a explicar hoy. Creamos una nueva aplicación MVVM Light para WPF, y añadimos la siguiente clase al modelo:

WPF2

How to: Use a Thumb to Enable Dragging. Void onDragStarted(object sender, DragStartedEventArgs e) { myThumb.Background = Brushes.Orange; } void onDragCompleted(object sender, DragCompletedEventArgs e) { myThumb.Background = Brushes.Blue; } For the complete sample, see Thumb Drag Functionality Sample.

How to: Use a Thumb to Enable Dragging

WPF RadioButtons in MVVM... Mitesh Sureja's Blog: How to use BackgroundWorker to update UI in WPF. InShare In this article I explained BackgroundWorker functionality using simple example.

Mitesh Sureja's Blog: How to use BackgroundWorker to update UI in WPF

In this example I am adding millions of number in background to the Listbox. During this addition UI will be responsive and user can do some other work. When update complete it will notify user about the same. How to enlarge or re-size Calendar in WPF DatePicker « Confessions of a .NET Developer! Printing in WPF. Printing FlowDocument in WPF This article demonstrates how to create a FlowDocument dynamically and print it in WPF.

Printing in WPF

Introduction. Using the Dispatcher with MVVM - David Rickard's Tech Blog. When writing an MVVM application, you want to separate from the UI.

Using the Dispatcher with MVVM - David Rickard's Tech Blog

However you also need to make sure that UI updates happen on the UI thread. Changes made through INotifyPropertyChanged get automatically marshaled to the UI thread, so in most cases you’ll be fine. However, when using INotifyCollectionChanged (such as with an ObservableCollection), these changes are not marshaled to the UI thread. This means that unless you modify your collection on the UI thread, you’ll get a cross threading error. Thus the problem. Mitesh Sureja's Blog: WPF Page Navigation. WPF provides support for browser style navigation inside standalone application using Page class.

Mitesh Sureja's Blog: WPF Page Navigation

User can create multiple pages, navigate between those pages along with data.There are multiple ways available to Navigate through one page to another page. WPF. Draggable objects and simple shape connectors. « Denis Vuyka. Last weekend I found very good sample of using Thumb class for implementing draggable objects.

WPF. Draggable objects and simple shape connectors. « Denis Vuyka

In two words as all other elements in WPF the Thumb also can be templated. And nothing stops you to get all drag functionality of Thumb turning it to anything you need. That’s perfect I think ;) So how to easily create a simple draggable object based on a Thumb? Here we declare a Thumb, set the “onDragDelta” handler for the “DragDelta” event and assign to it custom template called “template1″.

After that we create the most simpliest shape template that can be found everywhere in the internet. Draw over Image in WPF. MVVM Light Messaging. Posted on July 5, 2010 by Chris Koenig Since I started using the MVVM Light toolkit, I’ve gotten lots of questions about the it.

MVVM Light Messaging

In this post, I’m going to show you the basics of using the Messaging infrastructure. In the sample application attached, we have the situation where a Master page with a list of data items is trying to move to the Details page to show the details for one specific item. There are a couple of ways to do this, but the one I’ve starting using is the Messaging infrastructure in MVVM Light. It involves the ViewModels communicating with each other via a lightly-coupled messaging bus rather than a direct coupling or using the query string.

The sample application displays a fixed set of data elements in a list on the main page. Step 1 – Send the message out to the bus The RaisePropertyChanged method includes two overrides – this one publishes to the Messaging infrastructure for us. Step 2 – Register the Details view model to listen for the appropriate message. Sound Code: Using a WrapPanel with ItemsControl and ListView. I recently needed to put some items inside a WrapPanel in WPF, which I wanted to scroll vertically if there were too many items to fit into the available space.

Sound Code: Using a WrapPanel with ItemsControl and ListView

I was undecided on whether I wanted to use an ItemsControl or a ListView (which adds selected item capabilities), and discovered that when you switch between the two containers, the technique for getting the WrapPanel working is subtly different. ItemsControl is the simplest. Just set the ItemsPanelTemplate to be a WrapPanel, and then put the whole thing inside a ScrollViewer (sadly you can’t put the ScrollViewer inside the ItemsPanelTemplate): this produces the following results: WPF Multithreading: Using the BackgroundWorker and Reporting the Progress to the UI. I can’t count the number of times someone has asked me about running a time consuming task on a separate thread, but at the same time show a progress dialog with up-to-the-second percentage updates being displayed to the user.

Multithreading can be confusing at first, but if you just take it one step at a time, it really isn’t all that bad. WPF Videos. Commands in MVVM. Contents Introduction In this article I am going to describe how Commands work for projects that use MVVM (Model View View-Model). The approach I am describing works in exactly the same way whether you are using WPF, Silverlight, or Windows Phone 7. First, I will show a variety of ways that we can use commands in any MVVM project - this section works as a quick-reference for Commanding. Each example is then described in detail later on in the article - I will show exactly how the code works. The code used is part of my Apex MVVM library, however as each section is described with full code examples, you can easily integrate these methods into existing projects or libraries - or simply add Apex as a reference and get started straight away.