• Home
  • About
  • BestBloggingIdeas
  • DotNetLearningSource
  • FORUM
  • Joblinks
  • Latest News
  • Policy
  • POSTS
  • SimplySqlServer.Com && SimplyAspDotNet.Com
  • Sitemap

Join Ours Forum

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

RSS Feed
  • Bounty Huge Roll [Amazon Frustration-Free Packaging]
  • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
  • The Basic Overview of Windows Mobile Development Asp.Net C#
  • Overview of Sql server extended properties Asp.Net C#
  • How to Use Sql Server Extended properties using visual studio Asp.Net C#
  • Adobe Dreamweaver Templates Accelerate Web Development
  • Top Tips for Web Design Projects
  • How to Achieve a Good Web Design Structure
  • To Use Or Not To Use Website Templates
  • Five Tips to a Successful Website
  • Top 10 Articles,


    Silverlight Datagrid Select Update Delete Insert Asp.Net C#

    Differences Similarities Benefits Between Typed Datasets and Untyped Datasets asp.net c#

    Linq to Sql Introduction Entities Ado.Net C# SqlClasses Attributes Linq Mapping

    Linq Programming/How Linq Works?/Linq Implementation In Asp.Net C# Ado.Net

    Performing Developing Using Investigating Asp.Net 2.0 Ajax Application Development Asp.Net C#

    Hosting/Install Wcf Services in a Windows Service Asp.Net C#

    Connecting Silverlight to Wcf Asp.Net C#

    Silverlight Data Grid Data Binding WCF Asp.Net C#

    Invoking/Accessing/Calling WCF Service Without Adding/Creating Proxy/Reference Asp.Net C#

    Performing Doing Creating Insert Update Delete sql data Using Linq Database Asp.Net C#

    WPF Programming-All in one Actions

    Posted by on July 3, 2010 Leave a comment (7) Go to comments

    Introduction:
    In this article,i am going to explain how to do wpf programming in asp.net 3.5 and above
    .Net versions.And also in this article i am going to explain about wpf Elements,layouts,
    properties in wpf,

    1.Dependency Property,
    2.Attached Property,
    3.Routed Events,

    Main:
    Window Presentation Foundation to develop Rich User Interface applications using XAML .
    WPF based on Managed code (CLR) and declarative Programming (use xml-type e.g. )

    Main Goals for WPF are,

    1.To Use Modern Hardware,
    2.Simply Coding,
    3.To Separate Business logic from presentation,

    XAML Overview:

    1.XAML is simply a declarative language,
    2.Each and every elements representing CLR class,
    3.Most of the xaml elements correspond to a derived class from some abstract classes in CLR,

    WPF Elements:
    There are five kinds of elements in XAML,

    1.Root Elements:The root elements of xaml files.Window and page are common root elements,
    and window is more common.

    2.Panel Elements:These elements are used to layout user interfaces and keep other elements.
    StackPanel,DockPanel,Grid and Canvas are four panel elements.

    3.Control Elements:These elements are used to represent controls in XAML.

    4.Geometric Elements:These elements are used to draw a geometric shapes in XAML.

    5.Documentation Elements:Most Common usage of this element is when you want to
    change the presentation of a document.

    WPF Attributes:
    When elements represent .NET Clr classes their attribures represent class properties and
    that is true.So in an inheritence hierarchy each element inherits some properties from its
    parent.

    We has two option to define attributes,

    1.Inline Attributes :D efinition is similar to normal XML attributes.

    2.Explicit:In this option you declare attributes as a child of the parent element.
    Explicit option is a good choice when an element has many attributes.

    <Window x:Class="FirstWPFapp.Window1"  //ROOT ELEMENT DECLARATION 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" //PRIMARY NAMESPACE DECLARATION FOR THIS XAML CODE,
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  //SECONDARY NAMESPACE DECLARATION FOR THIS XAML CODE,
        Title="FirstWPFapp" Height="400" Width="364" FlowDirection="LeftToRight" Loaded="Window_Loaded">  //TITLE AND HEIGHT AND WIDTH OF THE XAML PAGE,
        <Grid>
            <StackPanel   Margin ="5">
            <Image  Source="Hydrangeas.jpg"  Width ="160" Height ="160"  />
          <Label Name="l1" HorizontalAlignment ="center"  FontSize ="24"  Content="WELCOME to WPF"/>
          <Label Name="l2" FontSize="20"  Content="Enter Your name"></Label>
          <TextBox  Name="t1" FontSize ="20"  Margin="5" Background ="Aqua"></TextBox>
          <Button Name="b1" Click="b1_Click" FontSize ="20" Margin="5"  Width="150" Background ="Yellow" Content="Greet"></Button>          
          </StackPanel>     
        </Grid>
    </Window>

    The WPF programming mainly contains the two parts named,
    1.Code –> Written in some .NET languages like C#,
    2.Markup –> Pure XAML part,

    WPF Layout Controls,

    STACKPANEL –> Will layout its children in a vertical or horizontal stack
    DOCKPANEL –> Allocate the entire edge of its client to each child
    GRID –> Arranges its child controls in rows and columns
    CANVAS –> Allows you to layout children freely using absolute position by setting their top,left,width and height properties

    Dependency Property,

    Dependency property is used with data binding,animation,styles,

    Whenever the value of a dependency property changes, WPF can automatically trigger a number of actions depending on the property’s metadata. These actions can be re-rendering the appropriate elements, updating the current layout, refreshing data bindings.

    built-in change notification is done through property triggers, which enable you to perform your own custom actions when a property value changes without writing any procedural code.

    for ex,

    <Window x:Class="WPFdependency_demo.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WPFdependency_demo" Height="335" Width="406"
        >
     
      <StackPanel  Margin ="10" Background ="Olive">
        <Slider Name ="sldvalue" Minimum ="0" Maximum ="100" Margin ="10" >
          </Slider>
        <TextBlock Name ="t1" HorizontalAlignment ="Center"
                   FontSize ="18" Margin ="10"  Width="350" ></TextBlock>
        <TextBox  Name="txt"  HorizontalAlignment ="Center" 
                  Width="200" FontSize="20"
                  Text="{Binding ElementName=sldvalue , Path=Value}"  ></TextBox>
      </StackPanel>
     
    </Window>

    Attached Property allows as use some attach some styles globalically,

    Attached Property:

    StackPanel panel = new StackPanel();
    TextElement.SetFontSize(panel, 30);
    TextElement.SetFontStyle(panel, FontStyles.Italic);
    panel.Orientation = Orientation.Horizontal;
    panel.HorizontalAlignment = HorizontalAlignment.Center;
    Button helpButton = new Button();
    helpButton.MinWidth = 75;
    helpButton.Margin = new Thickness(10);
    helpButton.Content = “Help”;
    Button okButton = new Button();
    okButton.MinWidth = 75;
    okButton.Margin = new Thickness(10);
    okButton.Content = “OK”;
    panel.Children.Add(helpButton);
    panel.Children.Add(okButton);

    Routed Events

    Routed events are events that are designed to work well with a tree of elements.
    When a routed event is raised, it can travel up or down the visual and logical tree, getting raised
    on each element in a simple and consistent fashion, without the need for any custom code.

    Routing Events Strategies
    Tunneling—The event is first raised on the root, then on each element down the tree until the
    source element is reached.

    Bubbling—The event is first raised on the source element, then on each element up the tree until
    the root is reached.

    Direct—The event is only raised on the source element.

    The tunning is normal event in WPF programming,

    Event Bubbling:

    In xaml file,

    <Window x:Class="WPFdependency_demo.Window3"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        MouseRightButtonDown="AboutDialog_MouseRightButtonDown"
        Title="Window3" Height="300" Width="300" Loaded="Window_Loaded">
        <Grid>
     
        </Grid>
    </Window>

    In Xaml.cs file,

    The Event will fire in window right click,

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
     
    namespace WPFdependency_demo
    {
        /// <summary>
        /// Interaction logic for Window3.xaml
        /// </summary>
        public partial class Window3 : Window
        {
            public Window3()
            {
                InitializeComponent();
            }
     
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
     
            }
     
            void AboutDialog_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
            {
                this.Title = "Source = " + e.Source.GetType().Name + ", OriginalSource = " + e.OriginalSource.GetType().Name + " @ " + e.Timestamp;
                Control source = e.Source as Control;
                if (source.BorderThickness != new Thickness(5))
                {
                    source.BorderThickness = new Thickness(5);
                    source.BorderBrush = Brushes.Black;
                }
                else
                    source.BorderThickness = new Thickness(0);
            }
     
        }
    }


    Conclusion:

    Hope this helps,
    Happy Coding.

    ASP.NET
    ← How to Develop/Create Asynchronous Client Program/Functionalities/Operations in WCF application
    Creating Socket Programming Using WCF NetTcpBinding and NetNamedPipeBinding →

    Learn Easily Using Video Tutorials


    How to choose the right Java IDE – explained Eclipse NetBeans BlueJ

    Developing/Creating/Performing/Configuring Java Applications Using Eclipse IDE

    Step By Step Guide for Download/Install Configure Eclipse IDE for Java

    Editing data with the GridView control Asp.Net C#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Best way to prepare asp.net Interview - Success Stories

    Download Important Questions and PPT's:

    Sql Server Important Questions Online free download

    Dotnet Important Questions Online free download

    Exploring Linq to Sql Process Flow

    Learn how to perform silverlight programming

    Learn OOPs concepts in better and well manner

    Learn Ajax in better and well manner

    Leave a comment

    7 Comments.

    1. Manual Partyka July 3, 2010 at 2:16 pm

      Thanks for the interesting post, can I ask where you get your information from?

    2. mining gold easy wow July 3, 2010 at 11:58 pm

      This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

    3. insurancebuild July 14, 2010 at 2:06 am

      Thank you for creating this web site! I am so happy to be able to watch the progress of this restoration. I am filled with admiration for what you are doing! Best of luck with your work.

    4. forex robot July 18, 2010 at 7:31 pm

      What a great resource!

    5. Zona Vigiano July 23, 2010 at 2:33 am

      Here is the 2nd instance I have come across your blog post in the last few weeks. Seems like I should take note of it.

    6. Kirby Bramucci July 28, 2010 at 10:54 am

      Nice post keep the good work.

    7. Vera Cornwell August 14, 2010 at 4:26 pm

      I am quite new to the internet and needed to read up on this subject. Thought it was a fantastic entry very well written and informative. I will surely be coming back to your site to read more posts as i adored this one..

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Enter your email address:

    Delivered by FeedBurner

    • Recent Posts

      • Bounty Huge Roll [Amazon Frustration-Free Packaging]
      • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
      • The Basic Overview of Windows Mobile Development Asp.Net C#
      • Overview of Sql server extended properties Asp.Net C#
      • How to Use Sql Server Extended properties using visual studio Asp.Net C#
    • Search by Tags!

      Application AspNet Basic between Black Bluetooth Build Business Collection Consultants Design Development Downloading effective Excel Experts Generics Implement Installing Interview Logic Management Microsoft Minutes Object Outlook Professional Programmer Programming Project Projects Questions Ready Select Server Services Silverlight Source Strings Studio Through using Visual Website Wordpress
    • Archives

      • August 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • December 2010
      • November 2010
      • October 2010
      • September 2010
      • August 2010
      • July 2010
      • June 2010
      • May 2010
      • April 2010
      • March 2010
      • February 2010
      • January 2010
      • December 2009
      • November 2009
      • October 2009
      • September 2009

    Copyright © 2012 NetProgrammingHelp.com

    Δ Top