Wednesday 30 April 2014

What's New in WPF 4.5


Hi Friends,

In this article I will tell  what are the new features added in WPF with 4.5
 
·         Ribbon control
o   WPF 4.5 added with a Ribbon control that hosts a Quick Access Toolbar, Application Menu, and tabs.

·             Improved performance when displaying large sets of grouped data

·             New features for the VirtualizingPanel

·             Binding to static properties
o   You can use static properties as the source of a data binding. The data binding engine recognizes when the property's value changes if a static event is raised

·             Accessing collections on non-UI Threads
o   WPF enables you to access and modify data collections on threads other than the one that created the collection. This enables you to use a background thread to receive data from an external source, such as a database, and display the data on the UI thread. By using another thread to modify the collection, your user interface remains responsive to user interaction.


·             Synchronously and Asynchronously validating data

·             Automatically updating the source of a data binding

·             Binding to types that Implement ICustomTypeProvider

·             Retrieving data binding information from a binding expression

·             Checking for a valid DataContext object

·             Repositioning data as the data's values change (Live shaping)

·             Improved Support for Establishing a Weak Reference to an Event

·             New methods for the Dispatcher class
The Dispatcher class defines new methods for synchronous and asynchronous operations.

·             Markup Extensions for Events
o   WPF 4.5 supports markup extensions for events. While WPF does not define a markup extension to be used for events, third parties are able to create a markup extension that can be used with events.



Happy Programming!!

Don’t forget to leave your feedback and comments below!

If you have any query mail me to Sujeet.bhujbal@gmail.com     

Regards
Sujeet Bhujbal
--------------------------------------------------------------------------------

----------------------------------------------------------------------------------

Saturday 26 April 2014

Adding WPF Windows to an existing Windows Form Project



Adding WPF Windows to an existing Windows Form Project

Last week I was working on one window application. In this application we have to add WPF window to existing Window form project


Following code describes how to add WPF window to existing Window form project

There are 2 ways we can add WPF window to existing window form application


1. Using Designer  Side


1.      Add reference to System.Windows.Forms and WindowsFormsIntegration.




Select System.Windows.Forms








Once these two references are added, we have access to all windows forms controls and access to the components that will allow us to embed them in WPF.






2. In the WPF Tool Box, we can see WindowsFormsHost control




Drag and Drop the WindowsFormsHost Control in WPF Window.

Our XAML is going to be extremely simple:




<Window x:Class = "Window1" >
xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="278" Width="587"
<Grid>
<WindowsFormsHost Name="WindowsFormsHost1" >

</Grid>
</Window







2. Using Code Behnind file



using System;
using System.Windows.Forms;
using System.Windows.Forms.Integration;

var wpfwindow = new WPFWindow.Window1();

ElementHost.EnableModelessKeyboardInterop(wpfwindow);

wpfwindow.Show();




In the above code The EnableModelessKeyboardInterop() call is necessary to handle keyboard input in the WPF window if loaded from a non-WPF host like WinForms.

Happy Programming!!

If you have any query mail me to Sujeet.bhujbal@gmail.com     


Regards

Sujeet Bhujbal

------------------------------------------------------------------------------------------------------------
---------------