Friday, 12 December 2014

Introduction

     In this article I am presenting a custom wizard control which supports MVVM approach. Here we will see how to use this control also we will see the features this control exposes. You can download this control from Github page. Contribution to this control will be appreciated. Also you can download the complete solution which makes use of this control from here. Once the wizard control is implemented, it will look like as shown below.


How to use this wizard control?

    This control comes in three files.

  1. Wizard.cs 
  2. WizardItemHeader.cs 
  3. IWizardItem.cs 

Wizard.cs is the main file which contains the implementation of this custom control. This file is dependent on WizardItemHeader.cs which is a structure that the control uses internally. If you are not following MVVM approach, then what you need is just these two files. If you are following MVVM then you will require IWizardItem.cs
IWizardItem.cs
This is an interface which when implemented in your ViewModel, will expose more features of this control. You have to optionally implement this interface in your ViewModel of the view(s) which you are going to display in wizard. The interface members are as shown below.
public interface IWizardItem
    {
        /// <summary>
        /// This method should return the header for wizard item to display
        /// </summary>
        /// <returns> A string value.</returns>
        string GetHeader();

        /// <summary>
        /// This method will be invoked to check whether this item can be displayed or not.
        /// </summary>
        /// <returns>A boolean value indicating true or false status</returns>
        bool CanDisplay();

        /// <summary>
        /// This method will get invoked when the wizard item becomes the active item.
        /// </summary>
        void OnWizardItemNavigatedTo();

        /// <summary>
        /// This method will get invoked on the current wizard item when the control is moved to next wizard item.
        /// </summary>
        void OnWizardItemNavigatedFrom();
    }

Now we will see how to use this wizard control in XAML. You can use this control just like any other control. The xaml declaration of this wizard control is as shown below.
<wizard:Wizard CancelCommand="{Binding CancelCommand}"

      OkCommand="{Binding OkCommand}"

      Orientation="Top"

      FinalButtonText="Done"

      WizardItems="{Binding WizardItems}" />

Here CancelCommand will be executed when user clicks on the cancel button. OkCommand is the command which will be executed when the user is in the final step and user clicks on the next button. Orientation is the way the wizard displays the items. Say for instance, if we assign the orientation as “Left” then the control will be displayed as shown below.


FinalButtonText is where we can assign the text to display on the next button when we are at the final stage of the wizard. Now finally WizardItems is where you have to assign the list of view objects. The control will take the view in its order as it is assigned in the list. Below is a sample initialization of the WizardItems.
public MainWindowViewModel()
 {
   WizardItems = new List<object> { new View1(), new View2(), new View3() };
 }

public IList<object> WizardItems { get; set; }

This control also has shortcuts the shortcut associated with the back button is LEFT Arrow key and the shortcut associated with next button is RIGHT arrow key.or Enter key



Some of the concerns are addressed in the continuation post of this and you can find it at http://gonetdotnet.blogspot.in/2015/09/article-continuation-of-wpf-wizard_30.html
This includes how to share object and how to control navigation and how to validate before navigation.

Wednesday, 10 December 2014

Introduction

In telerik WPF radgridview, when we apply grouping, we can find that some groups will automatically expand even if there is no user interaction. This mostly happens in scenario when there is some value change in rows which are grouped. This will also happen in other scenarios as well. This is a known bug in telerik radgridview at the time when this post is posted.
In this post you will find out how to block this bug with the help of a custom behavior. Here we will make use of mouse click event and GroupRowIsExpandedChanging events. Here subscribing to mouse click events may look tricky; in order to understand this, you have to refer to this post.

Introduction


In this post, we will find out how to find the group, if grouping is applied on the radgridview, in which the event occurred. Or how to find if the row clicked is group row or not.

If you have subscribed to the mouse click event properly, you will get call to the delegate which is registered to the click event. You can refer to this post for proper subscription of mouse click event.

Now if you are getting calls to the delegate, then it is easy to find the row in which the event occurred, you can refer to this post to find out how you can achieve this.

Now to find out how to find the group in which this event occurred, you have to do something like this as shown below.

How to achieve this?

private void GridViewRowMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
   var senderElm = e.OriginalSource as FrameworkElement;
   var currentRow = senderElm.ParentOfType<GridViewRow>();
   var parentGroup = senderElm.ParentOfType<GridViewGroupRow>();

   if (currentRow == null && parentGroup != null)
    {
       // clicked on grouped row.
    }

   if (currentRow != null)
    {
      // clicked on a row.
    }
}
Introduction

If you are able to subscribe to a mouse click event on a radgridView, then your immediate requirement could be to find the row in which the mouse click event occurred. In this post we will see how to achieve this. If you are not subscribing to mouse click event properly, then you can refer to this post.

Tuesday, 9 December 2014

Introduction

Subscribing to a row click event is not straight forward in WPF Telerik RadGridView. In this post we will see how we can achieve this.

Subscribing to a mouse click event would have been straight forward if all the rows were available at the time of gridview loaded event. But as in most scenarios, not all rows are available at this time, so when you subscribe to a normal Mouse Click event, only a click on the Header row will trigger the events. As the GridView can be updated with values at a later stage, it is not easy to subscribe to those rows which are loaded at a later stage.

Thursday, 23 October 2014

Introduction

   I was trying to use SQlite Backing Store for my Enterprise Library Caching block. When i try to run my application I started getting an exception an it was like this
System.ArgumentException was unhandled
Message=The type 'Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

How did i fix this.

  I was using database backing store and backing store required one reference to Microsoft.Practices.EnterpriseLibrary.Caching.Database. After adding a reference to the same, It got fixed.

Introduction

   I was working on a project which uses Enterprise Library to store cache data to database backing store and I encountered an exception as Activation error occurred while trying to get instance of type ICacheManager.
I believed I have the entire configuration done properly. But there was one important configuration missing. In this post we will see how to fix the exception which occurs while using Enterprise library to cache or log data to backing store say database or any backing store. This happens when we try to use database backing store and misses the steps which is required to setup database backing store. Now to have the database to hold the cache data, we need some tables and stored procedures.

How did I fix this exception

  Enterprise library will provide you with one command batch file which you need to run against your database. This batch file will run Sql commands against your database and will create the stored procedures and required tables. You can find this batch file at, “EntLib50Src\Blocks\Caching\Src\Database\Scripts”. This is just a relative path. Actual path may vary based on your installation. You can find two files here; one is CreateCachingDb.cmd which has command which will run one sql script which will create tables and stored procedures to your database. Second is CreateCachingDatabase.sql which will have sql query to create necessary stored procedures and tables. If you can’t find the scripts folder, then you may have to install the “Enterprise Library 5.0 - Source Code.msi” which comes along with Enterprise library 5.0 install.

Monday, 1 September 2014

This could be one of the required features if you are working on WPF. But this won’t work without some additional work. Here in this post we will see how we can drag and drop items from RadTreeView to RadGridView. This is achieved with the help of behaviors.

Tuesday, 26 August 2014

Introduction

Worried over this exception? This happens when you haven’t set the Path= on binding. By default WPF binding will take the Path= part by default. But on controls which have a two way binding by default, this seems to be not working. You may have to set it explicitly.

Thursday, 21 August 2014

TextWrapping is required when your text to display has to align itself inside a control. TextWrapping should work seamlessly when your control is of fixed height and width. But this won’t be the scenario in all cases. When we have a dynamic parent control whose width and height cannot be predicted, we would like the TextBlock which is placed inside it to adjust itself to fit into the container. In this case we would prefer to have TextBlock decide on the height and width based on the parent control. So we won’t set any width or height.

Wednesday, 23 July 2014

Introduction

Service has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element. This can happen if there is no proper endpoint configured for the service.
Introduction

Here we will see how to fix the exception, the .Net Framing mode being used is not supported by 'net.tcp://....' See the server logs for more details.

Introduction

If you are using netNamedPipeBinding for your communication then you may get an exception like
“There was an error reading from the pipe: Unrecognized error 109 (0x6d).”
Introduction

This fix is helpful if you are using WCF streaming and you got this exception while transferring huge file using data contract. If you are using streaming and the stream is transferred to or from WCF service, then you will get an exception like
“There was an error while trying to serialize parameter http://tempuri.org/:fileStream. The InnerException message was 'Type 'System.IO.FileStream' with data contract name 'FileStream: http://schemas.datacontract.org/2004/07/System.IO' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.”
Introduction

 In this article we will see how to transfer a huge file to and from WCF services efficiently. WCF supports streaming of data. We will use streaming to transfer huge file efficiently to and from a WCF service. This article is all about transferring file using streaming transfer mode in WCF and it does not enforce you to use streaming always, because of its limitations.
Introduction

 In this article, we will see how to create a simple WCF service. Then we will see how to host this WCF service in a console application with so called self-hosting. After that we will see how to expose service metadata via MEX endpoint. After that we will see how to create a proxy for the WCF service which has net.tcp and net.pipe endpoints using visual studio 2010.

Thursday, 10 July 2014


It is often a requirement when we use RadSplitContainer and we want to set width or height to RadSplitContainer. Here in this post we will see how to achieve this. When we use RadSplitContainer, we would like it to occupy a small space initially and if required we can drag it to take more space. This is normally achieved by setting the width for the control. If we are using two RadSplitContainer and if we wish to set these RadSplitContainer widths in 1:3 ratios, we may not be able to achieve this easily if you are not an expert in it. So here is a post to relieve your effort to achieve this.

Thursday, 26 June 2014

 RadPane in telerik controls can show a header. We normally use the Header property to set the header for RadPane. This works most of the time. But in some scenarios, say for example when we use nested RadPane, this kind of usage doesn't seem to work. The header suddenly disappears. This is a know issue in telerik.

Wednesday, 25 June 2014

Varnish is an HTTP accelerator or so called reverse proxy. Varnish is a type of proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as though they originated from the server or servers themselves. Varnish then caches those pages whose expiry header is set to some future date. This means those pages which won’t change until that date. Mostly static pages in a site will have expiry header so the next time when a client requests a page, varnish will look at the header to determine that the page has not expired. If not expired, then it will then serve that page without contacting the web server. This way, load on the server will be less. All static pages will be served by varnish without the knowledge of webserver.

After installing and configuring varnish, varnish will listen to the port where the client send request. Real web server will now sit as a backend for varnish, if varnish is not able to find the page in its cache, then it will request the backend webserver to get the page and varnish will serve that page to requesting client and at the same time it will cache it and next time it will serve the cached page.

Friday, 9 May 2014

Issue:

At times we will face with a situation where we need to show an image from another project in the same solution. Say for example: If you are building an enterprise application then we will modularize the application. And at times we want to show some image from this module in the main shell view. This at times can run you crazy. Here we will see how to show an image from a different module in the shell view.

Wednesday, 16 April 2014


Issue:

Often we face a situation where we have defined a DataTemplate and we need to bind to a property, most often to a Command in ViewModel. To achieve this we will define the binding and will set a RelativeSource for that binding which in some cases can ends up in an error like this. BindingExpression path error: … property not found on 'object' … BindingExpression:Path=… DataItem=…

Sunday, 13 April 2014

Issue:

When I was developing some XAML page, I encountered one situation where I experienced some intermittent bug from WPF. Some of my buttons will go disabled at times even if the CommandParameter bind to a buttons command has proper value to enable button. Below is the solution for this.
Issue: 

You all may have experienced an annoying behavior of visual studio while developing WPF XAML.
Say for example Visual Studio consumes large amounts of memory and shows Not Responding message on a regular basis while designing XAML
This is because of the XAML designer (Microsoft Visual Studio XAML UI Designer) which visual studio loads while editing XAML. There will be one for each XAML that you open for editing.
Issue:

While in the process of module initialization, if there is any error in a module, then PRISM will throw exception and will stop loading other modules until you fix the error in the module. But if your module is not really important in your application, you would like to suppress this module initialization error and continue loading other modules.
Issue:

You can achieve this with the help of Behavior in WPF. Create one multiselect behavior and attach it to RadGridView. This way you can avoid any code behind code altogether and can implement multiselect in proper MVVM way.
Issue: 

How to Sort RadGridView in ascending order based on a column value when it is loaded.

Introduction


     Here in this article I am introducing a WPF IP-Control. This control is a simple to use IP-Address control made out of WPF text box control. You can use this IP-Address control in any Microsoft WPF/Silverlight application. This control is inherited from TextBox control. This can be used like any text box control. But the display will be rendered to look like an IP-Address control. Below is the image of the proposed WPF IP-Address Control.




How to use this IP-Address Control? 

     Attached here in this article is the IP-Address Control class. You can download it from Github page. Contribution to this control is appreciated. It can be used like any other TextBox control. You can bind or enter any valid IP-Address value to this control but the output will be rendered in an IP-Address v4 format. Now we will see how we can use this control in a xaml.

<wizardDemo:IPControl Height="25" Width="100" Text="{Binding IPText, Mode=TwoWay}" />
Introduction:

In this article you will see how to implement multiselect in WPF DataGrid in proper way when you are following MVVM pattern. In this article you will see how to implement a behavior to your DataGrid so that we can achieve multiselect.
Behaviors are introduced with Expression Blend, to encapsulate pieces of functionality into a reusable component. These components can then be attached to controls to give them an additional behavior.
Issue: 

WPF Controls like DataGrid have default shortcut keys. For example, if you try to select any row and press Delete button then the grid row will be deleted. This is the default behavior. We can disable it in MVVM way by using InputBindings. InputBindings represents a binding between an input gesture and a command.
Issue:
 When you create an enterprise application, Keyboard shortcuts are a must. Enterprise applications will need keyboard shortcuts to execute certain actions in controls which are possible only by using mouse. Keyboard shortcut is different from keyboard access key where it will help you to get the focus on to control. Here we will use InputBindings to achieve this. InputBindings represents a binding between an input gesture and a command.