Archive for October, 2010

Convert MS Access/SQLExpress Database to SQLCE

Converting the existing access database to SQLCE is a pain as the SQLCE does not support create table sql queries.So to make our work easier there is a tool which makes it seamlessly easy.

Yes DataPortWizard (Check Here) tool from PrimeWork provides a easier wizard based solution for migration. It Quickly and easily transfer databases from the desktop to the Mobile Device and back. Data Port Wizard will make full copies of Microsoft Access or Microsoft SQL Server databases into SQL Server Compact Edition 4.0 (CTP1), 3.5 and 3.0, and SQL CE 2.0 databases – and back. Read the rest of this entry »

,

Leave a comment

ADO.Net Entity Framework

Well most of our application driven by a relational database and business layer associated with it.The amount of time spent to establish a communication between these two is quite a lot.So here Microsoft introduces a framework for easy data abstraction called Entity Framework (AEF).AEF does wonder with support of LINQ to Entity and here in this post we will have a detailed demonstration.

What Is Entity Framework

It is an abstraction conceptual schema over the logical database schema (Relational database) .It allows us to eradicate the O-R mismatch between RDBMS and the application logic which is common in  data driven applications .(O-R impedance mismatch ,(Details can be found here). Read the rest of this entry »

,

11 Comments

Dock Fill a control in parent control

In Win form , we used to have a Dock.Fill option for controls to stretch it with in parent control.But in WPF it is quite different.So this quick post will demonstrate ,how to fill a control inside a parent control.Suppose we want to dock fill a Button inside a layout.Lets create a button inside the layout. Read the rest of this entry »

, , ,

Leave a comment

Layout and Controls in WPF

Half of the battle can be won through UI and Control placement in software paradigm .All of us know the a good UI leaves extraordinary impact on user so this post is all about control placing and control layout in WPF.In this post we will cover following topics.

  1. Layout
  2. Classic Controls
Layout

Layout in WPF are versatile than win form controls.In Win form most of the frequently used layouts used the coordinate based control placement while in WPF it is slot based depending on the screen space.the most common used layouts in wpf are as follows :

  • Canvas
  • Used Coordinate based Control Layout (Same as panel in normal Win Form)
  • Stack Layout
  • Control are placed horizontally / Vertically one above the other
  • Wrap Layout
  • Controls are  placed sequentially horizontally / vertically
  • Grid Layout
  • Creates column,Row based grid and each cell allows controls to be placed
  • Dock Panel
  • Docks the control on specified area

    A collected sample of all can be seen bellow

     image

    More details can be found http://msdn.microsoft.com/en-us/library/ms745058.aspx.

    Classic Controls

    The control set in WPF is rich with wide support for data binding .A full comparison of WPF and winform control can be found from here.

    image

    Additional Link for Controls

    http://www.simple-talk.com/content/file.ashx?file=3354

    http://www.simple-talk.com/dotnet/.net-framework/from-winform-to-wpf-a-quick-reference-guide/

    , , ,

    Leave a comment

    Routed Event in WPF – Introduction

    Till date we were acquainted with normal event which are basics of Win Form Applications.WPF introduces a new concept called as Routed Event .So here we will have a brief intro for this new feature and comparison between CLR Events and Routed Events.We will not start with definition , instead we will go back to old methods of CLR event and try to achieve something funny but logically meaningful.

    Track Mouse Challenge (My niece 6 yrs old was tester , Still i failed  )

    So a very simple logic , Whenever the mouse moves with in the panel the Status Label should display as “With in Panel” or else “Outside Panel”.So what we need to do is ,track it with Mouse Move and Mouse Leave events .The logic and code follows as bellow.

    SNAGHTML1cffb48

    Code Snippet
    1. private void pnlContainer_MouseMove(object sender, MouseEventArgs e)
    2. {
    3. pnlContainer.BackColor = Color.Red;
    4. lblMouseLocation.Text= “With in Panel”;
    5. }
    6. private void pnlContainer_MouseLeave(object sender, EventArgs e)
    7. {
    8. pnlContainer.BackColor = Color.Cyan;
    9. lblMouseLocation.Text = “Ouside Panel”;
    10. }

    Very Simple .Lets Run.But the results are not as of requirement .So

    My Niece’s Bug Report

    When Ever the Mouse moves over the Black Board (Image Control) , status (Label Control) shows Outside Panel “ and that too logged on High Priority mode :).image Logically it should not happen .To patch it up in the end i attached event handler to the Image control .But suppose the panel contains more than one image or controls then how pathetic it will be to attach event to all .

    Year 2010 , I tried to implement same logic with WPF and it surprised me.

    Track Mouse Challenge  , in WPF

    Now with WPF i emulate the same logic as in my previous WinForm application and it worked .
    image and the code followed exactly same as above.

    Code Snippet
    1. private void pnlContainer_MouseMove(object sender, MouseEventArgs e)
    2. {
    3. pnlContainer.Background = Brushes.Red;
    4. lblMouseLocation.Content = “With in Panel”;
    5. }
    6. private void pnlContainer_MouseLeave(object sender, MouseEventArgs e)
    7. {
    8. pnlContainer.Background = Brushes.Cyan;
    9. lblMouseLocation.Content  = “With in Panel”;
    10. }

    e

    Download the compiled programs and Check it.

    Track Mouse Program (Simple WithOut WPF) Download
    Track Mouse Program (Simple in WPF) Download

    This is exactly where WPF introduces you to Routed Event.

    What Is Routed Events

    Routed events are the events that travel through the parent/ Child container of a control with raising  their events .The movement logic known as Routing Strategy (We will Digg into it in my next posts).

    So events can also be captured at parent or child container instead of the particular control which invokes it.

    Scenario Of Use

    I know you will not agree with the scenario as mentioned above .

    So some practical usage ,Consider a case of a normal calculator which contains 10 Numeric Button and Logical Operations .It is normal to write behind each control event , but what about code readability and scattered logic.Why should not we write a common logic part behind the parent container.

    Another simple usage is YEs,No,Cancel button used in all our form.image I can handle events of buttons in the container Boarder.

    Technical Difference From CLR Events

    WPF UI is a composite architecture based  , means a control can be consists of several other controls or resource .Lets have a look at the document outline of the TrackMouse application.The Border (Resembles to Panel in Winform) contains the image control element. image The events are also followed as of the VisualTree above .The events of Image Element can be handled at its parent element Border.In Mouse Track program , Mouse Move of Image is a Routed event which invokes the parent Border Mouse move event also.Try to debug the code .

    image I know the Technical details are not sufficient and the scope of the particular post doesn’t allow it .In my next posts i will cover the Routing Events and Routing Strategy in depth.

    Code for this Article -Routed Event Intro Download

    That’s it for now , i hope you liked my niece’s intelligence :).

    , , , , ,

    1 Comment

    Design a site like this with WordPress.com
    Get started