<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>databinding &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/databinding/</link>
	<description>Feed of posts on WordPress.com tagged "databinding"</description>
	<pubDate>Tue, 01 Dec 2009 03:50:56 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Ever Need a Sortable ObservableCollection?]]></title>
<link>http://victorgaudioso.wordpress.com/2009/11/30/ever-need-a-sortable-observablecollection/</link>
<pubDate>Tue, 01 Dec 2009 02:53:58 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/11/30/ever-need-a-sortable-observablecollection/</guid>
<description><![CDATA[Recently I had a ListBox bound to an ObservableCollection.  The powers that be wanted me to sort the]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Recently I had a ListBox bound to an ObservableCollection.  The powers that be wanted me to sort the items in the collection in alphabetical order.  Much to my surprise I found that this was not something built into a ListBox or into the ObservableCollection.  So, I set out to figure out how to do this in WPF.  I found a very cool posting on the Internet where this programmer (I&#8217;ll have to find his name and post it to give him credit) that showed me how to make a new class called SortableObservableCollection that extends the ObservableCollection but also adds functionality to sort it.  So, I built and it worked great.  So, I am sharing my code with you.  You can download my sample application here:</p>
<p><a href="http://tw0.us/5Fz">http://tw0.us/5Fz</a></p>
<p>You can either just add the reference assembly (found in the Debug/Bin folder of the zip) or you can just create a new class called SortableObservableCollection and copy the code from my class with the same name.</p>
<p>Enjoy!</p>
<p>Victor</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[DropDownList In GridView]]></title>
<link>http://gridview.wordpress.com/2009/11/09/dropdownlist-in-gridview/</link>
<pubDate>Mon, 09 Nov 2009 05:56:32 +0000</pubDate>
<dc:creator>Pon Saravanan</dc:creator>
<guid>http://gridview.wordpress.com/2009/11/09/dropdownlist-in-gridview/</guid>
<description><![CDATA[DropdownLists and GridView Dropdowns are basic controls just like a textbox with some items as a lis]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>DropdownLists and GridView</strong></p>
<p>Dropdowns are basic controls just like a textbox with some items as a list.. Basically the dropdowns have the AutoPostBack property to have a PostBack while selecting items. This can happen when placed in a template column in GridView as well.</p>
<p><strong>DropDownList in Markup<br />
</strong>Dropdown can be placed inside template columns in a gridview. It is practical to place  the dropdown in the EditItemTemplate. But for ease of explaining and easy understandings, I am keeping it under ItemTemplate.</p>
<p><strong>Bind the DropDownList </strong><br />
DropDownList is inside the ItemTemplate , Hence we can not access it directly. We have to get that using e.Row.FindControl(). This will give the control.</p>
<p>And we can get the Data Source using a SQL Client and assign to the DataSource. Before binding we need to setup a bit more info.The <em>DataTextField</em> is the field name which has to be shown in the screen. The <em>DataValueField </em>is the field name which has to be considered as a value for the respective text.</p>
<p><strong>How to Enable PostBack for the DropDownList is explained here(<a href="http://www.vbknowledgebase.com/?Id=108&#38;Desc=DropDownList-GridView-and-SelectedIndexChanged">DropDownList GridView and SelectedIndexChanged</a>)</strong></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[All of My Video Tutorials in One Place (revisited)]]></title>
<link>http://victorgaudioso.wordpress.com/2009/11/07/all-of-my-video-tutorials-in-one-place-revisited/</link>
<pubDate>Sun, 08 Nov 2009 04:26:57 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/11/07/all-of-my-video-tutorials-in-one-place-revisited/</guid>
<description><![CDATA[Hey All, This is a post that keeps growing day by  day so I need to update its postion to be at the ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hey All,</p>
<p>This is a post that keeps growing day by  day so I need to update its postion to be at the top of my blog as the content grows. So, here it is again by popular demand:</p>
<p>Create a Silverlight Ragdoll with Simulated Physics: <a href="http://tw0.us/4pA">http://tw0.us/4pA</a></p>
<p>How to create a functioning Silverlight Login UserControl: <a href="http://tw0.us/4o3">http://tw0.us/4o3</a></p>
<p>How to create a Silverlight Timer using the DispatcherTimer class: <a href="http://tw0.us/4my">http://tw0.us/4my</a></p>
<p>How to create custom RoutedEvents in Silverlight using Andrew Whiddett&#8217;s (IdentityMine) Eventing assembly reference: <a href="http://tw0.us/4cU">http://tw0.us/4cU</a></p>
<p>Use the Silverlight Toolkit&#8217;s WrapPanel to create a ListBox that displays three rows of Data: <a href="http://tw0.us/4aV">http://tw0.us/4aV</a></p>
<p>Create a Silverlight custom Silder: <a href="http://tw0.us/4LZ">http://tw0.us/4LZ</a></p>
<p>How to create a Visual Tree Helper to locate FrameworkElements in the Visual Tree: <a href="http://tw0.us/46C">http://tw0.us/46C</a></p>
<p>Using DataBinding to control the Visibility of any Silverlight Object using Blend and Visual Studio: <a href="http://is.gd/4jUYJ">http://is.gd/4jUYJ</a></p>
<p>How to create a complete Sketchflow Prototype in Silverlight: <a href="http://is.gd/41pjN">http://is.gd/41pjN</a></p>
<p>Creating a Custom Silverlight Button Just for Designers (using linear and radial gradients, the gradient tool and opacity masks): <a href="http://is.gd/3XAcr">http://is.gd/3XAcr</a></p>
<p>Creating a Custom Silverlight Button: <a href="http://is.gd/3X1eZ">http://is.gd/3X1eZ</a></p>
<p>Creating a Storyboard Helper Class:  <a href="http://is.gd/3mjXW">http://is.gd/3mjXW</a></p>
<p>Importing Photoshop PSD files into Expression Blend 3:<br />
<a href="http://is.gd/3f53d">http://is.gd/3f53d</a></p>
<p>Creating Morphing Vector Path Storyboards in Blend<br />
<a href="http://tw0.us/4oI">http://tw0.us/4oI</a></p>
<p>Re-Creating a Metallic Logo in Vector using Blend 3<br />
<a href="http://tw0.us/4oL">http://tw0.us/4oL</a><br />
 <br />
Creating Timed Storyboard Animations<br />
<a href="http://tw0.us/4oK">http://tw0.us/4oK</a><br />
 <br />
Using TemplateBinding to Replace a ContentPresenter in a Silverlight Button<br />
<a href="http://tw0.us/4oJ">http://tw0.us/4oJ</a><br />
 <br />
Working with Data in BLend 3<br />
<a href="http://tw0.us/4oN">http://tw0.us/4oN</a><br />
 <br />
Silverlight 3 Behavior Tutorial Video<br />
<a href="http://is.gd/3ajTP">http://is.gd/3ajTP</a><br />
 <br />
This Tutorial will teach you how to create a Card Flipping Animation!<br />
<a href="http://is.gd/3ajpa">http://is.gd/3ajpa</a> </p>
<p>Observable Collection Tutorial<br />
<a href="http://is.gd/3ajLK">http://is.gd/3ajLK</a></p>
<p>Silverlight Extended Drag and Drop Behavior:<br />
<a href="http://victorgaudioso.wordpress.com/2009/07/07/extended-drag-and-drop-behavior/">http://victorgaudioso.wordpress.com/2009/07/07/extended-drag-and-drop-behavior/q</a></p>
<p><a href="http://is.gd/3f53d"></a></p>
<p>Enjoy! Victor</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Databinding shapes with the Bing Maps control for Silverlight]]></title>
<link>http://davidburela.wordpress.com/2009/11/02/databinding-shapes-with-the-bing-maps-control-for-silverlight/</link>
<pubDate>Mon, 02 Nov 2009 04:53:47 +0000</pubDate>
<dc:creator>David Burela</dc:creator>
<guid>http://davidburela.wordpress.com/2009/11/02/databinding-shapes-with-the-bing-maps-control-for-silverlight/</guid>
<description><![CDATA[The March 2009 release of the Virtual Earth control for Silverlight (now known as the bing map contr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The March 2009 release of the Virtual Earth control for Silverlight (now known as the bing map control) was a great release. Up until then, projects like Deep Earth were trying to provide us with a way to use deep zoom + the virtual earth tiling to allow us to build Silverlight apps. Now Microsoft have given us an official control to play with.</p>
<p>One of the big downsides of the official control was the lack of databinding. You still had to add / remove your pushpins &#38; shapes manually just like you would with the AJAX version. There is code available on the Microsoft website that adds dependency properties to the Bing Maps control which expose ItemsCollection, ready for you to databind to. If you combine this with some custom datatemplates, you are able to databind directly to the map as you would expect.</p>
<h3>Step 1. Install the Bing Maps control</h3>
<p>The CTP of the control is available from Microsoft connect <a href="https://connect.microsoft.com/silverlightmapcontrolctp">https://connect.microsoft.com/silverlightmapcontrolctp</a></p>
<p> <!--more--><br />
<h3>Step 2. Download the databinding enabler</h3>
<p>You just need to download this single .cs file and include it in your project <a href="http://code.msdn.microsoft.com/VESLBindingProps">http://code.msdn.microsoft.com/VESLBindingProps</a></p>
<h3>Step 3. Add the Bing maps control to your .xaml page</h3>
<p>Add the virtual earth namespace for the control, the ve namespace for the dependency properties, and then the grid. It should look something like this</p>
<pre class="csharpcode"><span class="kwrd">&#60;</span><span class="html">UserControl</span> <span class="attr">x:Class</span><span class="kwrd">=&#34;SDDNTestRun.MainPage&#34;</span>
    <span class="attr">xmlns</span><span class="kwrd">=&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
    <span class="attr">xmlns:x</span><span class="kwrd">=&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
    <span class="attr">xmlns:d</span><span class="kwrd">=&#34;http://schemas.microsoft.com/expression/blend/2008&#34;</span>
    <span class="attr">xmlns:mc</span><span class="kwrd">=&#34;http://schemas.openxmlformats.org/markup-compatibility/2006&#34;</span>
    <span class="attr">xmlns:VirtualEarth</span><span class="kwrd">=&#34;clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl&#34;</span>
    <span class="attr">xmlns:ve</span><span class="kwrd">=&#34;clr-namespace:Synergist.VE&#34;</span>
    <span class="attr">mc:Ignorable</span><span class="kwrd">=&#34;d&#34;</span> <span class="attr">d:DesignWidth</span><span class="kwrd">=&#34;640&#34;</span> <span class="attr">d:DesignHeight</span><span class="kwrd">=&#34;480&#34;</span><span class="kwrd">&#62;</span>
    <span class="kwrd">&#60;</span><span class="html">Grid</span> <span class="attr">x:Name</span><span class="kwrd">=&#34;LayoutRoot&#34;</span> <span class="kwrd">&#62;</span>
        <span class="kwrd">&#60;</span><span class="html">VirtualEarth:Map</span> <span class="attr">x:Name</span><span class="kwrd">=&#34;MyMap&#34;</span>
                <span class="attr">CopyrightVisibility</span><span class="kwrd">=&#34;Collapsed&#34;</span> <span class="attr">LogoVisibility</span><span class="kwrd">=&#34;Collapsed&#34;</span> <span class="attr">Mode</span><span class="kwrd">=&#34;Aerial&#34;</span><span class="kwrd">&#62;</span>
        <span class="kwrd">&#60;/</span><span class="html">VirtualEarth:Map</span><span class="kwrd">&#62;</span>
    <span class="kwrd">&#60;/</span><span class="html">Grid</span><span class="kwrd">&#62;</span>
<span class="kwrd">&#60;/</span><span class="html">UserControl</span><span class="kwrd">&#62;</span></pre>
<h3>Step 4. Add the data template for shapes and the map layer</h3>
<p>This data template to databind polyshapes is fairly easy. You just need to set the polyshape style (thickness, colour, etc.) and then databind the points to the locations collection</p>
<pre class="csharpcode">&#60;DataTemplate x:Key=<span class="str">&#34;MapShape&#34;</span>&#62;
    &#60;VirtualEarth:MapPolygon Fill=<span class="str">&#34;Orange&#34;</span> Stroke=<span class="str">&#34;Green&#34;</span> StrokeThickness=<span class="str">&#34;2&#34;</span> Opacity=<span class="str">&#34;0.4&#34;</span> Locations=<span class="str">&#34;{Binding}&#34;</span> /&#62;
&#60;/DataTemplate&#62;</pre>
<p>And here is how you add the layer to the map</p>
<pre class="csharpcode">&#60;VirtualEarth:Map x:Name=<span class="str">&#34;MyMap&#34;</span>
    CopyrightVisibility=<span class="str">&#34;Collapsed&#34;</span> LogoVisibility=<span class="str">&#34;Collapsed&#34;</span> Mode=<span class="str">&#34;Aerial&#34;</span>&#62;
    &#60;VirtualEarth:MapLayer x:Name=<span class="str">&#34;ShapeLayer&#34;</span>
        ve:Properties.ItemsSource=<span class="str">&#34;{Binding}&#34;</span>
        ve:Properties.ItemTemplate=<span class="str">&#34;{StaticResource MapShape}&#34;</span> /&#62;
&#60;/VirtualEarth:Map&#62;</pre>
<h3>Step 5. Add some data to the layer</h3>
<p>This is the fun bit, figure out what the coordinates for your shape are and create a collection for it. Myself, i’m going to use the site of the Microsoft office here in Melbourne. I’m just going to do this in the page constructor in the code behind</p>
<pre class="csharpcode">MyMap.Center = <span class="kwrd">new</span> Location(-37.8222600730785, 144.962552763317);
MyMap.ZoomLevel = 17;

var shapeList = <span class="kwrd">new</span> ObservableCollection&#60;LocationCollection&#62;
{
<span class="kwrd">new</span> LocationCollection
    {
        <span class="kwrd">new</span> Location(-37.8217176782418, 144.961662269924),
        <span class="kwrd">new</span> Location(-37.8214041044085, 144.962391830776),
        <span class="kwrd">new</span> Location(-37.8222346484096, 144.963314510677),
        <span class="kwrd">new</span> Location(-37.8228194135791, 144.962638594005),
        <span class="kwrd">new</span> Location(-37.8223617716666, 144.961887575481),
        <span class="kwrd">new</span> Location(-37.8220397256568, 144.962005592678),
    }
};
ShapeLayer.DataContext = shapeList;</pre>
<h3>Step 6. Hit run and see your databinding in action!</h3>
<p>Because we are databinding to an observable list, we can just add new items to it and watch the new shapes appear. It is also possible to add extra points to an existing shape, and see it update live on the map.</p>
<p>If you want to add an extra shape, add this to a click event to see the databinding happening interactively</p>
<pre class="csharpcode">shapeLists.Add(<span class="kwrd">new</span> LocationCollection()
{
    <span class="kwrd">new</span> Location(-37.8207645163828, 144.961630711604),
    <span class="kwrd">new</span> Location(-37.8200356576319, 144.96164144044),
    <span class="kwrd">new</span> Location(-37.8197136014726, 144.96321857934),
    <span class="kwrd">new</span> Location(-37.8206882408042, 144.962092051554)
});</pre>
<h3>Step 7. Pushpins</h3>
<p>Pushpins are a little more involved. Here i have created a “Point of Interest” class, that has the location and extra details. Here i’m just going to use the location property to databind to. The good thing is that you can use any control as your pushpin. In the included sample my PushPin control expands out when you hover, and collapses when you move off it.</p>
<pre class="csharpcode"><span class="kwrd">&#60;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">=&#34;MicrosoftPushPin&#34;</span><span class="kwrd">&#62;</span>
    <span class="kwrd">&#60;</span><span class="html">Controls:PushPin</span> <span class="attr">VirtualEarth:MapLayer</span>.<span class="attr">MapPosition</span><span class="kwrd">=&#34;{Binding Loc}&#34;</span>
        <span class="attr">VirtualEarth:MapLayer</span>.<span class="attr">MapPositionMethod</span><span class="kwrd">=&#34;Center&#34;</span>  <span class="kwrd">/&#62;</span>
<span class="kwrd">&#60;/</span><span class="html">DataTemplate</span><span class="kwrd">&#62;</span></pre>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> POI
{
    <span class="kwrd">public</span> <span class="kwrd">string</span> Loc { get; set; }
    <span class="kwrd">public</span> <span class="kwrd">string</span> Description { get; set; }
}

<span class="rem">//In the class constructor</span>
PushPinLayer.DataContext = <span class="kwrd">new</span> ObservableCollection&#60;POI&#62;
{
   <span class="kwrd">new</span> POI() { Loc = <span class="str">&#34;-37.8222600730785, 144.962552763317&#34;</span> }
};</pre>
<h3>Sample app</h3>
<p><a href="http://davidburela.files.wordpress.com/2009/11/image.png"><img style="display:inline;border-width:0;" title="image" border="0" alt="image" src="http://davidburela.files.wordpress.com/2009/11/image_thumb.png?w=223&#038;h=244" width="223" height="244" /></a></p>
<p>In case you just want to see it working, I’ve included the demo I built live at the Melbourne Silverlight Desiginer &#38; Developer Network. Good luck!</p>
<p><a href="http://cid-fc3a2c38819e3e29.skydrive.live.com/self.aspx/Blog/VirtualEarthBindingDemo.zip">http://cid-fc3a2c38819e3e29.skydrive.live.com/self.aspx/Blog/VirtualEarthBindingDemo.zip</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Question &amp; Answer 1]]></title>
<link>http://sevenlamp.wordpress.com/2009/10/23/question-answer-1/</link>
<pubDate>Fri, 23 Oct 2009 09:36:20 +0000</pubDate>
<dc:creator>sevenlamp</dc:creator>
<guid>http://sevenlamp.wordpress.com/2009/10/23/question-answer-1/</guid>
<description><![CDATA[ကြၽန္ေတာ္ သူငယ္ခ်င္းတို႔ရဲ႕ comment ထဲမွာ ေမးတဲ႔ ေမးခြန္းေလးေတြကို အလွ်င္းသင့္သလို ျပန္ေျဖနိုင္ေအာင္]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:justify;"><span style="color:#339966;">ကြၽန္ေတာ္ သူငယ္ခ်င္းတို႔ရဲ႕ comment ထဲမွာ ေမးတဲ႔ ေမးခြန္းေလးေတြကို အလွ်င္းသင့္သလို ျပန္ေျဖနိုင္ေအာင္ဆိုျပီး Question and Answer ဆိုတဲ႔ အပို္င္းေလး ထည့္ဖို႔ စဥ္းစားမိတယ္။ ဒါနဲ႔ ဒီ category ေလးကို စလိုက္ပါတယ္။ သူငယ္ခ်င္းတို႔ C# နဲ႔ ပတ္သက္ျပီး သိခ်င္တာေလးေတြ ေမးနိုင္ပါတယ္။ ကြၽန္ေတာ္ သိသေလာက္ ေျဖေပးပါ့မယ္။ အဲ မသိရင္လည္း ၾကိဳးစား ရွာဖတ္ျပီး ေျဖေပးနိုင္ေအာင္ ၾကိဳးစားပါ့မယ္။</span></p>
<p>အရင္ဆံုး Ko Thet ေမးတဲ႔ ေမးခြန္းေလးနဲ႔ စလိုက္ရေအာင္….</p>
<p><span style="color:#ff00ff;"><strong>Q</strong><strong> :</strong> <strong><em>How to populate data in text box by using combo box.Says, Chose ID in Combo Box, then Name, Add, City, Contact no and etc will be shown in respective text box control. If you have time, please show me.</em></strong></span></p>
<p><span style="color:#ff00ff;"><cite><strong>Comment by </strong></cite><strong><em>Ko Thet</em></strong><cite><strong> — October 22, 2009 </strong></cite></span></p>
<p>A : ဒီေမးခြန္းေလးအတြက္ ကြၽန္ေတာ္ example program ေလး တစ္ခု ေရးျပပါမယ္။ အရင္ဆံုး ေအာက္မွာ ျပထားတဲ႔ ပံု(၁) အတိုင္း database ထဲမွာ table ေလး တစ္ခုေဆာက္လိုက္ပါတယ္။</p>
<p>Database name =&#62; <strong>Course_DB</strong></p>
<p>Table name =&#62; <strong>EmployeeTable</strong></p>
<p><strong> </strong></p>
<div class="wp-caption alignnone" style="width: 434px"><strong><strong><img title="pic_1" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_1.png" alt="pic_1" width="424" height="431" /></strong></strong><p class="wp-caption-text">pic_1</p></div>
<p><strong> </strong></p>
<p><strong><em>Note</em></strong><em>: EmployeeID ကို ကြၽန္ေတာ္တို႔ ထည့္စရာ မလိုပဲ database မွာ auto တိုးသြားခ်င္လို႔ အဲ့ဒီ column properties မွာ (Is Identity) ကို Yes လို႔ ေပးလိုက္ပါတယ္။ Identity Seed (1) ကေနစျပီး Identity Increment (1) စီ တိုးသြားမယ္လို႔ ေျပာတာပါ။</em></p>
<p>ျပီးရင္ အဲ့ဒီ EmployeeTable ထဲကို Sample Data နည္းနည္း ျဖည့္ေပးထားလိုက္ပါမယ္။ ပံု(၂) နဲ႔ ပံု(၃)မွာ ၾကည့္ပါ။</p>
<div class="wp-caption alignnone" style="width: 283px"><img title="pic_2" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_2.png" alt="pic_2" width="273" height="129" /><p class="wp-caption-text">pic_2</p></div>
<div class="wp-caption alignnone" style="width: 464px"><img title="pic_3" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_3.png" alt="pic_3" width="454" height="128" /><p class="wp-caption-text">pic_3</p></div>
<p>database ေဆာက္ျပီးေတာ့ အခုကြၽန္ေတာ္တို႔ program ဘက္အပိုင္းကို ဆက္ပါမယ္။ New Window Application တစ္ခုယူျပီး ပံု(၄) အတိုင္း design ခ်လိုက္ပါတယ္။</p>
<div class="wp-caption alignnone" style="width: 312px"><img title="pic_4" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_4.png" alt="pic_4" width="302" height="226" /><p class="wp-caption-text">pic_4</p></div>
<p>Database ထဲက data ကို window form မွာ ခ်ိတ္ျပဖို႔အတြက္ ကြၽန္ေတာ္ အခု ပံု(၅) မွာျပထားသလို အဆင့္ဆင့္ လုပ္သြားလိုက္ပါ။</p>
<div class="wp-caption alignnone" style="width: 532px"><img title="pic_5" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_5.png" alt="pic_5" width="522" height="365" /><p class="wp-caption-text">pic_5</p></div>
<div class="wp-caption alignnone" style="width: 584px"><img title="pic_6" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_6.png" alt="pic_6" width="574" height="452" /><p class="wp-caption-text">pic_6</p></div>
<p style="text-align:justify;">Data Source Configuration Wizard မွာ ‘DataBase’ ကိုေရြးျပီး Next ထပ္ႏွိပ္လိုက္ပါ။ ဒါဆိုရင္ ပံု(၇) မွာ ျပထားသလို database connection ေရြးခိုင္းတဲ႔ ေနရာကိုေရာက္ပါမယ္။ ကြၽန္ေတာ္တို႔က အခုမွ connection အသစ္ေဆာက္မွာ ျဖစ္လို႔ New Connection button ကိုႏွိပ္လိုက္ပါ။ Add connection wizard ေရာက္ရင္ ပံု(ဂ) မွာ ျပထားသလိုမ်ိဳး connection တစ္ခု ေဆာက္လိုက္ပါ။</p>
<div class="wp-caption alignnone" style="width: 583px"><img title="pic_7" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_7.png" alt="pic_7" width="573" height="448" /><p class="wp-caption-text">pic_7</p></div>
<div class="wp-caption alignnone" style="width: 393px"><img title="pic_8" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_8.png" alt="pic_8" width="383" height="574" /><p class="wp-caption-text">pic_8</p></div>
<div class="wp-caption alignnone" style="width: 585px"><img title="pic_9" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_9.png" alt="pic_9" width="575" height="450" /><p class="wp-caption-text">pic_9</p></div>
<p style="text-align:justify;">ပံု(၉) မွာ ျပထားတဲ႔ အတိုင္း ကြၽန္ေတာ္တို႔ database connection တစ္ခုရပါျပီ။ အဲ့ဒီ connection string ထဲမွာ password ထည့္သိမ္းထားမယ္ဆိုရင္ ဒုတိယ radio button ေလးကို ေရြးေပးရပါမယ္။</p>
<div class="wp-caption alignnone" style="width: 585px"><img title="pic_10" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_10.png" alt="pic_10" width="575" height="450" /><p class="wp-caption-text">pic_10</p></div>
<p>ေနာက္တစ္ဆင့္မွာ connection setting ေလးကို သိမ္းမလားလို႔ ေမးပါတယ္။ အိုေက သိမ္းထားလိုက္ပါ… နာမည္ကိုလည္း မေျပာင္းတာေကာင္းပါတယ္။</p>
<div class="wp-caption alignnone" style="width: 585px"><img title="pic_11" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_11.png" alt="pic_11" width="575" height="450" /><p class="wp-caption-text">pic_11</p></div>
<p style="text-align:justify;">အခုကြၽန္ေတာ္တို႔ combobox ကေနတဆင့္ dataset ေဆာက္တဲ႔ အဆင္ျပီးသြားပါျပီ။ အခု ေျပာသလိုမေဆာက္ခ်င္ဘူး ဒါမွမဟုတ္လည္း ကြၽန္ေတာ္တို႔ form ထဲမွာ combobox မပါဘူးဆိုရင္လည္း dataset ၾကီးပဲ ဒီတိုင္း ယူျပီး ေဆာက္လို႔လည္း ရပါတယ္။ (Project Menu -&#62; Add New Items -&#62; DataSet )</p>
<div class="wp-caption alignnone" style="width: 538px"><img title="pic_12" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_12.png" alt="pic_12" width="528" height="347" /><p class="wp-caption-text">pic_12</p></div>
<p>Code file ထဲမွာလည္း Form_Load event ကို auto ေဆာက္ေပးသြားပါလိမ့္မယ္။</p>
<div style="background-color:lightgray;padding:5px;">
<pre>private void Form1_Load(object sender, EventArgs e)
{
      this.employeeTableTableAdapter.Fill(this.course_DBDataSet.EmployeeTable);
}
</pre>
</div>
<p style="text-align:justify;">Database ထဲက data ေတြကို ကြၽန္ေတာ္တို႔ program ရဲ႕ memory ေပၚမွာ ယူျပီး သိမ္းေပးထားတဲ႔ အလုပ္ကို DataSet က လုပ္ေပးပါတယ္။ အဲ့ဒီ dataset ထဲကို data ေတြ ပို႔ေဆာင္ေပးတဲ႔ အလုပ္ကိုေတာ့ tableadapter က တာ၀န္ယူပါတယ္။ Form Load event ထဲမွာ ေရးေပးသြားတဲ႔ အလုပ္က အဲ့ဒီ data fill လုပ္ေပးတဲ႔ အလုပ္ပါ။ DataSet ထဲက data ေတြကို UI Controls ေတြမွာ ျပဖို႔ အတြက္ကိုေတာ့ BindingSource ကိုသံုးရပါတယ္။</p>
<p style="text-align:justify;">
<div class="wp-caption alignnone" style="width: 485px"><img title="pic_13" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_13.PNG" alt="pic_13" width="475" height="132" /><p class="wp-caption-text">pic_13</p></div>
<p style="text-align:justify;">အခု program ေလးကို အခုေန run လိုက္ရင္ combobox ထဲမွာ employee no ေတြကိုေတြ႔ေနရမွာပါ။ ဒါေပမယ့္ textbox ေတြမွာေတာ့ ေပၚမွာ မဟုတ္ေသးပါဘူး။ ကြၽန္ေတာ္တို႔ textbox ေတြနဲ႔ မခ်ိတ္ေပးရေသးဘူးေလ။ အိုေက အခု textbox ေတြနဲ႔ bindingsource နဲ႔ ခ်ိတ္ေပးပါ့မယ္။</p>
<div class="wp-caption alignnone" style="width: 322px"><img title="pic_14" src="http://sites.google.com/site/sevenlamp/forcourse/QNA1_14.png" alt="pic_14" width="312" height="305" /><p class="wp-caption-text">pic_14</p></div>
<p style="text-align:justify;">Textbox နဲ႔ databind ဖို႔အတြက္ textbox ရဲ႕ properties window ကိုသြားလိုက္ပါ။ အေပၚဆံုးနားမွာ (DataBindings) ဆိုတဲ႔ property ေလးကို ဖြင့္လိုက္ျပီး၊ Text property ကိုႏွိပ္လိုက္ပါ။ အဲ့ဒီမွာ ကြၽန္ေတာ္တို႔ form မွာ ရွိေနတဲ႔ employeeTableBindingSource ကိုေတြရပါမယ္။ အဲ့ဒီ bindingsource ထဲကေန ကြၽန္ေတာ္တို႔ textbox မွာ ျပခ်င္တဲ႔ column name ကိုေရြးေပးလိုက္ရံုပါပဲ။ ကဲ… က်န္တဲ႔ textbox ေတြအားလံုးမွာလည္း ဒီတိုင္းပဲ လိုက္လုပ္လိုက္ပါ။ အခုဆိုရင္ေတာ့ Ko Thet လိုခ်င္တဲ႔ Program ပံုစံေလး ရျပီထင္ပါတယ္။</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Forms DataBinding - The magic sequence of BindUI/UnbindUI]]></title>
<link>http://jonnybekkum.wordpress.com/2009/10/20/forms-databinding-the-magic-sequence-of-binduiunbindui/</link>
<pubDate>Tue, 20 Oct 2009 20:35:38 +0000</pubDate>
<dc:creator>jonnybekkum</dc:creator>
<guid>http://jonnybekkum.wordpress.com/2009/10/20/forms-databinding-the-magic-sequence-of-binduiunbindui/</guid>
<description><![CDATA[If you are developing Windows Forms apps and using Csla you may get errors like &#8220;EditLevelMism]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>If you are developing Windows Forms apps and using Csla you may get errors like &#8220;EditLevelMismatch in CopyState&#8221; or se that data values are overwritten when the dataobject is connected to the UI, diconnected from the UI or when the Form is disposed. And often/typically this happends when ComboBoxes are used on the form.</p>
<p>The reasion this happends is because you are  making logical errors in your code with regards to DataBinding.</p>
<p>Csla 3.6 introduces the CslaActionExtender and additional helper classes to automate BindUI and UnbindUI but there are times when you really need to do this manually and this article will show you how to this in a proper way. The CslaActionExtender is covered in Rockys book &#8220;Expert C# 2008 Business Objects&#8221; so I will not cover here.</p>
<p>Whenever it is necessary to handle Bund/Unbind manually I always recommend to create the following methods in your form:</p>
<table border="1">
<pre>private void BindUI()
{
    // Bind ComboBox list datasources first
    BindingHelper.RebindBindingSource(customerTypeNameValueListBindingSource,
                                        CustomerTypeNameValueList.GetNameValueList());

    // Bind dataobjects - starting with root object, child, grandchild and so on....
    BindingHelper.RebindBindingSource(testRootBindingSource, MyRoot);
}

private void UnbindUI(bool cancel)
{
    // Unbind in the opposite sequence of BindUI
    BindingHelper.UnbindBindingSource(testRootBindingSource, cancel, true);
    BindingHelper.UnbindBindingSource(customerTypeNameValueListBindingSource, false, false);
}</pre>
</table>
<p><strong>The correct sequence for BindUI is:</strong></p>
<ol>
<li><strong>First always bind the datasorces for lists used in ComboBoxes</strong></li>
<li><strong>Next bind the root object</strong></li>
<li><strong>If needed bind the child and grand child objects in that order</strong></li>
</ol>
<p><strong>The correct sequence for Unbind is the reverse sequence of BindUI.</strong></p>
<p>Why is the sequence so important? When databinding is active on one of the properties SelectedValue, SelectedItem or Text on a ComboBox the value vill be written to the underlying boound property when the prtoperty value is changed. This will happen if the list items does not exist or is removed whild databinding is active. So the key is to make sure that list items exists <strong>before </strong>the dataobject is connected to BindingSource (bound) and list items are <strong>removed </strong>only after the dataobject has been disconnected (unbound).</p>
<p>The last pitfall is if you (the developer) does not disconnect dataobjects from the UI when the form is closed. The sequence og disposing BindingSource will be undetermined and may or may not cause the same problems. To fix this you should always make sure to call UnbindUI in the FormClosed event.</p>
<table border="1">
<pre>    private void MyForm_FormClosed(object sender, FormClosedEventArgs e)
    {
      UnbindUI(true);
    }
</pre>
</table>
<p>The sematics for Save operation is as follows:</p>
<table border="1">
<pre>
  private void SaveMyRoot()
  {
    // assumes dataobject is valid for save, should thest for IsSavable

    UnbindUI(false);
    try
    {
      MyRoot = MyRoot.Save();
    }
    catch (DataPortalException ex)
    {
      // Handle exception the way you waant
    }
    finally
    {
      BindUI();
    }
</pre>
</table>
<p>If you download the code from <a href="http://cslacontrib.codeplex.com">CslaContrib</a> you will find a small helper class in MyCsla.Windows.BindingHelper that helps you to do a correct Bind and Unbind: </p>
<table border="1">
<pre>
public static class BindingHelper
{

	///
	/// Unbinds the binding source and the Data object. Use this Method to safely disconnect the data object from a BindingSource before saving data.
	///
	/// The source.
	/// if set to true then call CancelEdit else call EndEdit.
	/// if set to true this BindingSource contains the Root object. Set to false for nested BindingSources
	public static void UnbindBindingSource(BindingSource source, bool cancel, bool isRoot)
	{
		IEditableObject current = null;
		// position may be -1 if bindigsource is already unbound which results in Exception when trying to address current
		if ((source.DataSource != null) &#38;&#38; (source.Position &#62; -1)) {
			current = source.Current as IEditableObject;
		}

		// set Raise list changed to True
		source.RaiseListChangedEvents = false;
		// tell currency manager to suspend binding
		source.SuspendBinding();

		if (isRoot) source.DataSource = null;
		if (current == null) return;

		if (cancel)
		{
			current.CancelEdit();
		}
		else
		{
			current.EndEdit();
		}
	}

	///
	/// Rebinds the binding source.
	///
	/// The source.
	/// The data.
	public static void RebindBindingSource(BindingSource source, object data)
	{
		RebindBindingSource(source, data, false);
	}

	///
	/// Rebinds the binding source.
	///
	/// The source.
	/// The data.
	/// if set to true then metadata (ovject/list type) was changed.
	public static void RebindBindingSource(BindingSource source, object data, bool metadataChanged)
	{
		if (data != null)
		{
			source.DataSource = data;
		}

		// set Raise list changed to True
		source.RaiseListChangedEvents = true;
		// tell currency manager to resume binding
		source.ResumeBinding();
		// Notify UI controls that the dataobject/list was reset - and if metadata was changed
		source.ResetBindings(metadataChanged);
	}
}
</pre>
</table>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Add Checkbox column to GridView ]]></title>
<link>http://gridview.wordpress.com/2009/10/17/add-checkbox-column-to-gridview/</link>
<pubDate>Sat, 17 Oct 2009 14:48:45 +0000</pubDate>
<dc:creator>Pon Saravanan</dc:creator>
<guid>http://gridview.wordpress.com/2009/10/17/add-checkbox-column-to-gridview/</guid>
<description><![CDATA[Adding checkbox column to GridView at runtime dynamically If you are looking for a very neat and reu]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Adding checkbox column to GridView at runtime dynamically</strong></p>
<p>If you are looking for a very neat and reusable code, then you may consider reading furthert. It actually reduces a lot of duplication.</p>
<p><strong>Adding Checkbox Column at design time to GridView</strong><br />
Adding Checkbox column at design time is straight forward and you can modify the Checkbox at markup. If you still need the <strong>Checkbox </strong>to be  created at runtime. then this article is written focused on that. </p>
<p><strong>Adding Checkbox Column at runtime dynamically to GridView<br />
</strong>We need  to follow the same hierarchy as the TemplateField. So we must create a TemplateField ItemTemplate, EditItemTemplate, and HeaderTemplate. In our case we are trying only ItemTemplate for making it simpler. And adding these objects should happen at Init. For better understanding read with complete working source code for <a href="http://www.vbknowledgebase.com/?Id=90&#38;Desc=Adding-checkbox-column-to-GridView-dynamically">Adding checkbox column to GridView dynamically</a></p>
<p><strong>CheckBoxTemplate Custom Template for CheckBox</strong><br />
This CheckBoxTemplate gets ColumnName as input for fetching the data.   This class must implement ITemplate to behave as a custom template. If the ITemplate is implemented it has to implement InstantiateIn method.</p>
<p><strong>InstantiateIn from ITemplate<br />
</strong>Here the checkbox gets created in. Once control is created it has to be bound to the data. DataBinding event has to be handled for filling up the data for the checkbox. The data can be fetched from the GridViewRow’s DataItem Object.</p>
<p>Read further here for <a href="http://www.vbknowledgebase.com/?Id=90&#38;Desc=Adding-checkbox-column-to-GridView-dynamically">Dynamically Add Checkbox column to GridView </a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[My Speaking Schedule from Oct. to Dec. 2009]]></title>
<link>http://victorgaudioso.wordpress.com/2009/10/16/my-speaking-shedule-from-oct-to-dec-2009/</link>
<pubDate>Sat, 17 Oct 2009 02:23:21 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/10/16/my-speaking-shedule-from-oct-to-dec-2009/</guid>
<description><![CDATA[Greetings All! Below is a list of Silverlight Presenation engagements I have booked for Oct., Nov., ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Greetings All!</p>
<p>Below is a list of Silverlight Presenation engagements I have booked for Oct., Nov., and Dec. 2009.  If you are in Southern California I urge you to stop by and check it out; I am going to show off some awesome features of Silverlight and Blend.</p>
<p><strong>First Event: LA Silverlight User Group</strong>:</p>
<p>Date: Oct. 28, 2009</p>
<p>Time: 700pm &#8211; 900pm</p>
<p>Address:<br />
Microsoft LA    <br />
333 South Grand Ave, Suite 3300<br />
Los Angeles, CA 90071</p>
<p>Presenters:<br />
<a href="http://victorgaudioso.wordpress.com/about/">Victor Gaudioso</a><br />
<a href="http://www.cynergysystems.com/blogs/page/rickbarraza">Rick Barraza</a></p>
<p>My Presentation:<br />
1. Working with Sample Data in Blend 3:<br />
     a. Blend 3&#8217;s Data panel;<br />
     b. Creating Sample Data in Blend;<br />
          A. Showing Sample Data in a ListBox using List Mode;<br />
          B. Editing the ListBox DataTemplate to change the way the Sample Data is displayed;<br />
          C. Showing Sample Data in a TextBlock using Details Mode;<br />
          D. Importing XML and creating a Data Source;<br />
     c. Creating a Data Object in Visual Studio;<br />
     d. Creating an Observable Collection of Data Objects in Visual Studio;<br />
     e. Creating a DataSource from the Observable Collection in Blend;<br />
     f. Binding the DataSource to a ListBox in Blend</p>
<p><strong>Second Event: LA Dot Net, the Premiere Los Angeles .NET Developers Group</strong></p>
<p>Date: Nov. 2, 2009</p>
<p>Time: 700pm &#8211; 900pm</p>
<p>Address: UCLA</p>
<p>Presenters: Victor Gaudioso</p>
<p>My Presentation: To Be Determined (TBD)</p>
<p><strong>Third Event: LA C# (</strong><a href="http://www.lacsharp.org"><strong>www.lacsharp.org</strong></a><strong>)</strong></p>
<p>Date: Dec. 1, 2009</p>
<p>Address:<br />
Manhattan Beach</p>
<p>Time: 600 pm &#8211; 8:30 pm</p>
<p>Presenters: Victor Gaudioso</p>
<p>My Presentation: TBD</p>
<p><strong>Fourth Event: SocalDotNet (</strong><a href="http://www.socaldotnet.org"><strong>www.socaldotnet.org</strong></a><strong>)</strong> </p>
<p>Date: Dec. 2, 2009</p>
<p>Time: 600 &#8211; 8:30 pm</p>
<p>Address: Buena Park</p>
<p>Presenters: Victor Gaudioso</p>
<p>My Presentation: TBD</p>
<p>For more information email me at wpfauthor at gmail dot com.</p>
<p>Victor</p>
<p>Click <a href="http://victorgaudioso.wordpress.com/about/">HERE </a>for my Bio</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[New Silverlight Video Tutorial: Visibility Binding - Data Binding an Object's Visibility to a Boolean Property]]></title>
<link>http://victorgaudioso.wordpress.com/2009/10/14/new-silverlight-video-tutorial-visibility-binding-data-binding-an-objects-visibility-to-a-boolean-property/</link>
<pubDate>Thu, 15 Oct 2009 00:51:44 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/10/14/new-silverlight-video-tutorial-visibility-binding-data-binding-an-objects-visibility-to-a-boolean-property/</guid>
<description><![CDATA[Hello All, Is this tutorial I show you how you can use DataBinding to bind an object&#8217;s Visibli]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hello All,</p>
<p>Is this tutorial I show you how you can use DataBinding to bind an object&#8217;s Visiblity to a boolean property using a VisibilityConverter and a DependencyProptery. </p>
<p>You can find the code for the DependencyProperty and VisibilityConverter in this text file (the video will show you how/when to use it) <a href="http://windowspresentationfoundation.com/VisibilityBindingTutorial/VisibilityBindingNotes.txt">Here</a>:</p>
<p>You can download my zipped application <a href="http://windowspresentationfoundation.com/VisibilityBindingTutorial/VisibilityBindingTutorial.zip">Here</a>:</p>
<p>Finally, you can watch the video <a href="http://windowspresentationfoundation.com/VisibilityBindingTutorial/VisibilityBinding.wmv">Here</a>:</p>
<p>Enjoy!</p>
<p>Victor</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[All of my Video Tutorials in One Place]]></title>
<link>http://victorgaudioso.wordpress.com/2009/09/11/all-of-my-video-tutorials-in-one-place/</link>
<pubDate>Fri, 11 Sep 2009 23:58:45 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/09/11/all-of-my-video-tutorials-in-one-place/</guid>
<description><![CDATA[Hell All! I realized that I have all of my video tutorial links spread out across a bunch of differe]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Hell All!</p>
<p>I realized that I have all of my video tutorial links spread out across a bunch of different posts.  So I decided to compile a list of URLs for all of my video tutorials and blog it.  So, here is the Silverlight video tutorial list:</p>
<p>How to create Custom RoutedEvents in Silverlight (Thanks to Andrew Whiddett and IdentityMine for this One): <a rel="nofollow" href="http://tw0.us/4cU" target="_blank">http://tw0.us/4cU</a></p>
<p>Use the Silverlight Toolkit&#8217;s WrapPanel to create a ListBox that displays three rows of Data: <a href="http://tw0.us/4aV">http://tw0.us/4aV</a></p>
<p>Create a Silverlight custom Silder: <a href="http://tw0.us/4LZ">http://tw0.us/4LZ</a></p>
<p>How to create a Visual Tree Helper to locate FrameworkElements in the Visual Tree: <a href="http://tw0.us/46C">http://tw0.us/46C</a></p>
<p>Using DataBinding to control the Visibility of any Silverlight Object using Blend and Visual Studio: <a href="http://is.gd/4jUYJ">http://is.gd/4jUYJ</a></p>
<p>How to create a complete Sketchflow Prototype in Silverlight: <a href="http://is.gd/41pjN">http://is.gd/41pjN</a></p>
<p>Creating a Custom Silverlight Button Just for Designers (using linear and radial gradients, the gradient tool and opacity masks): <a href="http://is.gd/3XAcr">http://is.gd/3XAcr</a></p>
<p>Creating a Custom Silverlight Button: <a href="http://is.gd/3X1eZ">http://is.gd/3X1eZ</a></p>
<p>Creating a Storyboard Helper Class:  <a href="http://is.gd/3mjXW">http://is.gd/3mjXW</a></p>
<p>Importing Photoshop PSD files into Expression Blend 3:<br />
<a href="http://is.gd/3f53d">http://is.gd/3f53d</a></p>
<p>Creating Morphing Vector Path Storyboards in Blend<br />
<a href="http://is.gd/2R1br">http://is.gd/2R1br</a></p>
<p>Re-Creating a Metallic Logo in Vector using Blend 3<br />
<a href="http://is.gd/2ONQR">http://is.gd/2ONQR</a><br />
 <br />
Creating Timed Storyboard Animations<br />
<a href="http://is.gd/2M7m9">http://is.gd/2M7m9</a><br />
 <br />
Using TemplateBinding to Replace a ContentPresenter in a Silverlight Button<br />
<a href="http://is.gd/2GDRy">http://is.gd/2GDRy</a><br />
 <br />
Working with Data in BLend 3<br />
<a href="http://is.gd/3ak0Q">http://is.gd/3ak0Q</a><br />
 <br />
Silverlight 3 Behavior Tutorial Video<br />
<a href="http://is.gd/3ajTP">http://is.gd/3ajTP</a><br />
 <br />
This Tutorial will teach you how to create a Card Flipping Animation!<br />
<a href="http://is.gd/3ajpa">http://is.gd/3ajpa</a> </p>
<p>Observable Collection Tutorial<br />
<a href="http://is.gd/3ajLK">http://is.gd/3ajLK</a></p>
<p>Silverlight Extended Drag and Drop Behavior:<br />
<a href="http://victorgaudioso.wordpress.com/2009/07/07/extended-drag-and-drop-behavior/">http://victorgaudioso.wordpress.com/2009/07/07/extended-drag-and-drop-behavior/q</a></p>
<p><a href="http://is.gd/3f53d"></a></p>
<p>Enjoy! Victor</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using TemplateBinding to Replace a ContentPresenter in a Silverlight Button]]></title>
<link>http://victorgaudioso.wordpress.com/2009/08/30/using-templatebinding-to-replace-a-contentpresenter-in-a-silverlight-button/</link>
<pubDate>Sun, 30 Aug 2009 00:57:33 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/08/30/using-templatebinding-to-replace-a-contentpresenter-in-a-silverlight-button/</guid>
<description><![CDATA[I have found that you have much more control over things such as centering text when using a TextBlo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I have found that you have much more control over things such as centering text when using a TextBlock instead of a ContentPresenter in a Silverlight custom Button Control.  In this short video (about 5 min) I show you how to repleace a Silverlight Button&#8217;s ContentPresenter with a TextBlock and then use Template Binding to have it display the correct button label.</p>
<p>Have fun!</p>
<p>Video URL:</p>
<p><a href="http://tw0.us/4oJ">http://tw0.us/4oJ</a><a href="http://www.windowspresentationfoundation.com/Tutorials/TemplateBindingTutorial.wmv"></a></p>
<p>&#160;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Manually Navigating a DevExpress DataLayoutControl]]></title>
<link>http://mrdeeptech.wordpress.com/2009/08/16/manually-navigating-a-devexpress-datalayoutcontrol/</link>
<pubDate>Sun, 16 Aug 2009 11:22:16 +0000</pubDate>
<dc:creator>Sam Winstanley</dc:creator>
<guid>http://mrdeeptech.wordpress.com/2009/08/16/manually-navigating-a-devexpress-datalayoutcontrol/</guid>
<description><![CDATA[Introduction In a scenario where you have a hierarchical (DevExpress) XPO data structure in the exam]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2>Introduction</h2>
<p>In a scenario where you have a hierarchical (<a href="http://www.devexpress.com/">DevExpress</a>) <a href="http://www.devexpress.com/Products/NET/ORM/">XPO</a> data structure in the example I am going to use Customers and Licenses, where 1 customer can have multiple licenses. For example:</p>
<p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:dc67a2e6-57e8-4a98-b7b2-2de0ff202467" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:none;font-family:Courier New;font-size:11.25px;"><span style="color:#000000;">    </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">class</span><span style="color:#000000;"> Customer : XPObject
    {
        </span><span style="color:#0000FF;">#region</span><span style="color:#000000;"> Constructors</span><span style="color:#000000;">
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> Name;
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> DateTime DateAdded;
        [Association(</span><span style="color:#800000;">"</span><span style="color:#800000;">Customer-Licenses</span><span style="color:#800000;">"</span><span style="color:#000000;">)]
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> XPCollection</span><span style="color:#000000;">&#60;</span><span style="color:#000000;">License</span><span style="color:#000000;">&#62;</span><span style="color:#000000;"> Licenses { </span><span style="color:#0000FF;">get</span><span style="color:#000000;"> { </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> GetCollection</span><span style="color:#000000;">&#60;</span><span style="color:#000000;">License</span><span style="color:#000000;">&#62;</span><span style="color:#000000;">(</span><span style="color:#800000;">"</span><span style="color:#800000;">Licenses</span><span style="color:#800000;">"</span><span style="color:#000000;">); } }
    }
    </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">class</span><span style="color:#000000;"> License : XPObject
    {
        [Association(</span><span style="color:#800000;">"</span><span style="color:#800000;">Customer-Licenses</span><span style="color:#800000;">"</span><span style="color:#000000;">)]
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> Customer Customer;
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> DateTime IssueDate;
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> DateTime ExpiryDate;
        [Association(</span><span style="color:#800000;">"</span><span style="color:#800000;">License-LicenseFeatures</span><span style="color:#800000;">"</span><span style="color:#000000;">)]
        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> XPCollection</span><span style="color:#000000;">&#60;</span><span style="color:#000000;">LicenseDetails</span><span style="color:#000000;">&#62;</span><span style="color:#000000;"> LicenseDetails
        {
            </span><span style="color:#0000FF;">get</span><span style="color:#000000;">
            { </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> XPCollection</span><span style="color:#000000;">&#60;</span><span style="color:#000000;">LicenseDetails</span><span style="color:#000000;">&#62;</span><span style="color:#000000;">(</span><span style="color:#800000;">"</span><span style="color:#800000;">LicenseDetails</span><span style="color:#800000;">"</span><span style="color:#000000;">); }
        }
    }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<ol>
<li>User Selects a Customer on the Main form.<br />
    </li>
<li>User Selects a License on the Main Form.<br />
    </li>
<li>User presses and Edit License button, which opens a new form allowing them to edit the specific license.<br />
    </li>
<li>User modifies the details in the new form.<br />
    </li>
<li>User clicks the save button.<br />
    </li>
</ol>
<h2>How the UI Looks</h2>
<p>The main form is based on a <a href="http://www.devexpress.com/Help/?document=XtraLayoutControl">DataLayoutControl</a> which is bound to an XPCollection&#60;Customer&#62;. The DataGrid inside the form is Bound to the same XPCollection&#60;Customer&#62; with a DataMember of Licenses so that it only shows the licenses attached to a specific customer record. <img src="http://mrdeeptech.files.wordpress.com/2009/08/081609_1121_manuallynav1.png" /></p>
<p>If you select a specific license then click on the View/Create license button, this opens another form which looks like this:</p>
<p>&#160;<img src="http://mrdeeptech.files.wordpress.com/2009/08/081609_1121_manuallynav2.png" /></p>
<p>This form is also driven by a DataLayoutControl and it is bound to an XPCollection of License.</p>
<h2>The Custom Data Binding</h2>
<p>You might have noticed that there is no DatabaseNavigator or similar on the LicenseForm but we need it to automatically select a given record based on what was selected on the Main form. Providing we can pass the correct record into the constructor of the form we have several options.</p>
<h3>Launching the child form</h3>
<h2>
  <br /></h2>
<p>There is 1 clear option which would involve creating a criteria on the XPCollection that the LicenseForm is bound to based on the License object that is passed in. However I also wanted to be able to create a new License if a null License was passed in, and the way for doing this did not seem immediately obvious especially as I wanted to be able to pre-select the customer that the License object was attached to. But I did find a way as follows: </p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e301e785-6de9-403b-9568-5bc662f7fdb0" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:none;"><span style="color:#000000;">        </span><span style="color:#0000FF;">private</span><span style="color:#000000;"> </span><span style="color:#0000FF;">void</span><span style="color:#000000;"> btnViewLicense_Click(</span><span style="color:#0000FF;">object</span><span style="color:#000000;"> sender, EventArgs e)
        {
            </span><span style="color:#008000;">//</span><span style="color:#008000;">Get the currency manager that my dataLayoutControl is currently using
            </span><span style="color:#008000;">//</span><span style="color:#008000;">to navigate and get the Current Customer object from that</span><span style="color:#008000;">
</span><span style="color:#000000;">            CurrencyManager manager </span><span style="color:#000000;">=</span><span style="color:#000000;"> dataLayoutControl1.BindingContext[dataLayoutControl1.DataSource,dataLayoutControl1.DataMember] </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> CurrencyManager;
            LicenseDatabase.Customer cust </span><span style="color:#000000;">=</span><span style="color:#000000;"> manager.Current </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> LicenseDatabase.Customer;

            </span><span style="color:#0000FF;">int</span><span style="color:#000000;">[] selectedRows </span><span style="color:#000000;">=</span><span style="color:#000000;"> licenseGridView.GetSelectedRows();
            </span><span style="color:#0000FF;">object</span><span style="color:#000000;"> oRow </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">;
            LicenseForm frm1;
            </span><span style="color:#008000;">//</span><span style="color:#008000;"> if the grid has a selection</span><span style="color:#008000;">
</span><span style="color:#000000;">            </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (selectedRows.Length </span><span style="color:#000000;">&#62;</span><span style="color:#000000;"> </span><span style="color:#800080;">0</span><span style="color:#000000;">)
            {
                oRow </span><span style="color:#000000;">=</span><span style="color:#000000;"> licenseGridView.GetRow(selectedRows[</span><span style="color:#800080;">0</span><span style="color:#000000;">]);
                frm1 </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> LicenseForm(oRow </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> LicenseDatabase.License, cust);
            }
            </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#008000;">//</span><span style="color:#008000;">pass a null License record but the selected customer record</span><span style="color:#008000;">
</span><span style="color:#000000;">            {
                frm1 </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> LicenseForm(</span><span style="color:#0000FF;">null</span><span style="color:#000000;">, cust);
            }

            frm1.ShowDialog();

        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>&#160;</p>
<p>The first line here really does the magic:<br />
  <br /><span style="font-family:courier new;font-size:10pt;"><strong><span style="color:#2b91af;">CurrencyManager</span> manager = (CurrencyManager) dataLayoutControl1.BindingContext[dataLayoutControl1.DataSource,dataLayoutControl1.DataMember]<span style="color:blue;">;</span></p>
<p></strong></span></p>
<p>The DataLayoutControl is all based on Microsofts <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx">CurrencyManager</a> object for navigation, its all context based. The line is getting the currency manager which is currently attached to the dataLayoutControl for customers. This allows us to easily get a reference to the currently selected Customer record to pass to our child form, even if this customer record is not committed it is not a problem because we are all inside the same unit of work. <span style="font-family:courier new;font-size:10pt;"><br />
    <br /></span></p>
<h3>How the child form&#8217;s constructor works</h3>
<h2>
  <br /></h2>
<p>Looking at the constructor for the child form we have the following:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:77364718-10ef-4230-b958-5c77256974ce" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;white-space:pre-wrap;overflow:none;"><span style="color:#000000;">        CurrencyManager manager;

        </span><span style="color:#0000FF;">public</span><span style="color:#000000;"> LicenseForm(LicenseDatabase.License license,LicenseDatabase.Customer customer)
        {
            InitializeComponent();
            manager </span><span style="color:#000000;">=</span><span style="color:#000000;"> dataLayoutControl1.BindingContext[dataLayoutControl1.DataSource, dataLayoutControl1.DataMember] </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> CurrencyManager;
            </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (license </span><span style="color:#000000;">!=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;">)
            {
                </span><span style="color:#0000FF;">int</span><span style="color:#000000;"> index </span><span style="color:#000000;">=</span><span style="color:#000000;"> manager.List.IndexOf(license);
                manager.Position </span><span style="color:#000000;">=</span><span style="color:#000000;"> index;
            }
            </span><span style="color:#0000FF;">else</span><span style="color:#000000;">
            {
                manager.EndCurrentEdit();
                manager.AddNew();
                LicenseDatabase.License currentLicense </span><span style="color:#000000;">=</span><span style="color:#000000;"> manager.Current </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> LicenseDatabase.License;
                currentLicense.Customer </span><span style="color:#000000;">=</span><span style="color:#000000;"> customer;

            }
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This is making more use of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx">CurrencyManager</a> object this time using the one attached to the DataLayoutControl on the child form. Finally we have a small amount of code attached to the Save button of the LicenseForm as follows:</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8223c2c4-8c5a-4666-a48a-7f564aa0eef5" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:none;"><span style="color:#000000;">        </span><span style="color:#0000FF;">private</span><span style="color:#000000;"> </span><span style="color:#0000FF;">void</span><span style="color:#000000;"> btnSave_Click(</span><span style="color:#0000FF;">object</span><span style="color:#000000;"> sender, EventArgs e)
        {
            LicenseDatabase.License currentLicense </span><span style="color:#000000;">=</span><span style="color:#000000;"> manager.Current </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> LicenseDatabase.License;
            manager.EndCurrentEdit();
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<h2>In Summary</h2>
<p>If you like the DataLayoutControl from <a href="http://www.devexpress.com/Products/NET/Controls/WinForms/Layout/">Devexpress XtraLayout</a> objects which I do but you want to manually produce the kind of behaviour that you would get from a DataNavigator object without actually using one, you can do this using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx">CurrencyManager</a> object.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[A base class for Domain Models]]></title>
<link>http://johnhmarks.wordpress.com/2009/08/14/a-base-class-for-domain-models/</link>
<pubDate>Fri, 14 Aug 2009 16:49:16 +0000</pubDate>
<dc:creator>johnhmarks</dc:creator>
<guid>http://johnhmarks.wordpress.com/2009/08/14/a-base-class-for-domain-models/</guid>
<description><![CDATA[I just wrote a base class that I&#8217;m going to derive all of my notifying Domain Models from. It ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I just wrote a base class that I&#8217;m going to derive all of my notifying Domain Models from.  It solves the horror of passing around the property name of a changing property in the INotifyPropertyChanged implementation.  This has the enormous benefit of being able to check your Property Names at compile-time and also allows you to keep everything in sync when using tools like Resharper (if you don&#8217;t use Resharper &#8211; then you really should!) to rename things.  It uses lambda expressions to specify the Property that&#8217;s changing.</p>
<pre class="brush: csharp;">
    public abstract class ModelBase&lt;T&gt; : INotifyPropertyChanged where T : ModelBase&lt;T&gt;
    {
        #region Events
        public event PropertyChangedEventHandler PropertyChanged;
        #endregion

        #region Public Methods
        public static string GetPropertyName&lt;R&gt;(Expression&lt;Func&lt;T, R&gt;&gt; expression)
        {
            var memberExpression = expression.Body as MemberExpression;
            if (memberExpression == null)
            {
                throw new ArgumentException(&quot;'expression' should be a member expression&quot;);
            }
            var propertyName = memberExpression.Member.Name;
            return propertyName;
        }
        #endregion

        #region Protected Methods
        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected void RaisePropertyChanged&lt;R&gt;(Expression&lt;Func&lt;T, R&gt;&gt; expression)
        {
            var propertyName = GetPropertyName(expression);
            this.OnPropertyChanged(propertyName);
        }
        #endregion
}
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Weak INotifyPropertyChanged and INotifyCollectionChanged Listeners]]></title>
<link>http://johnhmarks.wordpress.com/2009/08/14/weak-inotifypropertychanged-and-inotifycollectionchanged-listeners/</link>
<pubDate>Fri, 14 Aug 2009 15:23:39 +0000</pubDate>
<dc:creator>johnhmarks</dc:creator>
<guid>http://johnhmarks.wordpress.com/2009/08/14/weak-inotifypropertychanged-and-inotifycollectionchanged-listeners/</guid>
<description><![CDATA[Following on from my woes about ObservableCollection&lt;T&gt;, and my annoyance at having to maintai]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Following on from my <a href="http://johnhmarks.wordpress.com/2009/08/12/annoyances-with-observablecollection/" target="_blank">woes about ObservableCollection&#60;T&#62;</a>, and my annoyance at having to maintain a parallel collection to ensure all INotifyPropertyChanged and INotifyCollectionChanged subscriptions are removed, I decided to look down the avenue of Weak event subscriptions.  To that end I can up with the classes WeakPropertyChangedListner and WeakCollectionChangedListener.  The code for these is as follows:</p>
<p> </p>
<pre class="brush: csharp;">
    public class WeakPropertyChangedListener
    {
        #region Private Fields
        private INotifyPropertyChanged _source;
        private WeakReference _listener;
        #endregion

        #region Ctor
        public WeakPropertyChangedListener(INotifyPropertyChanged source, PropertyChangedEventHandler listener)
        {
            this._source = source;
            this._source.PropertyChanged += this.OnPropertyChanged;
            this._listener = new WeakReference(listener);
        }
        #endregion

        #region Public Methods
        public static WeakPropertyChangedListener Create(INotifyPropertyChanged source, PropertyChangedEventHandler listener)
        {
            return new WeakPropertyChangedListener(source, listener);
        }

        public void Disconnect()
        {
            if (_source != null)
            {
                _source.PropertyChanged -= this.OnPropertyChanged;
                _source = null;
                _listener = null;
            }
        }
        #endregion

        #region Private Methods
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (_listener != null)
            {
                var handler = _listener.Target as PropertyChangedEventHandler;
                if (handler != null)
                {
                    handler(sender, e);
                }
                else
                {
                    this.Disconnect();
                }
            }
        }
        #endregion
    }
</pre>
<p>and:</p>
<pre class="brush: csharp;">
    public class WeakCollectionChangedListener
    {
        #region Private Fields
        private INotifyCollectionChanged _source;
        private WeakReference _handler;
        #endregion

        #region Ctor
        public WeakCollectionChangedListener(INotifyCollectionChanged source, NotifyCollectionChangedEventHandler handler)
        {
            this._source = source;
            this._source.CollectionChanged += this.OnCollectionChanged;
            this._handler = new WeakReference(handler);
        }
        #endregion

        #region Public Methods
        public static WeakCollectionChangedListener Create(INotifyCollectionChanged source, NotifyCollectionChangedEventHandler handler)
        {
            return new WeakCollectionChangedListener(source, handler);
        }

        public void Disconnect()
        {
            if (_source != null)
            {
                _source.CollectionChanged -= this.OnCollectionChanged;
                _source = null;
                _handler = null;
            }
        }
        #endregion

        #region Private Methods
        private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (_handler != null)
            {
                var handler = _handler.Target as NotifyCollectionChangedEventHandler;
                if (handler != null)
                {
                    handler(sender, e);
                }
                else
                {
                    this.Disconnect();
                }
            }
        }
        #endregion
    }
</pre>
<p> Then you simple subscribe like this:</p>
<pre class="brush: csharp;">
WeakPropertyChangedListener.Create(person, OnPersonPropertyChanged);

WeakCollectionChangedListener.Create(person.Children, OnPersonCollectionChanged);
</pre>
<p>Safe in the knowledge that your observing the notifications will not cause your domain objects to hang around.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Annoyances with ObservableCollection]]></title>
<link>http://johnhmarks.wordpress.com/2009/08/12/annoyances-with-observablecollection/</link>
<pubDate>Wed, 12 Aug 2009 15:35:47 +0000</pubDate>
<dc:creator>johnhmarks</dc:creator>
<guid>http://johnhmarks.wordpress.com/2009/08/12/annoyances-with-observablecollection/</guid>
<description><![CDATA[&lt;rant&gt; Thought I&#8217;d share with you some of my gripes with the ObservableCollection&lt;T]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>&#60;rant&#62;</p>
<p>Thought I&#8217;d share with you some of my gripes with the ObservableCollection&#60;T&#62; class that forms the basis of just about all data-bindable domain models in WPF and Silverlight.</p>
<p>Firstly why does it not support an AddRange(IEnumerable&#60;T&#62; items) method like other collections?</p>
<p>The EventHandler signature looks like:</p>
<p>private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)</p>
<p>and NotifyCollectionChangedEventArgs has a property NewItems of type IList.  This implies that you should be able to add multiple items, but the API doesn&#8217;t support it.  Infuriating!</p>
<p>More importantly, when you Clear an ObservableCollection you get called on the CollectionChanged event with NotifyCollectionChangedAction.Reset.  However when you look at e.OldItems you&#8217;d expect to find the list of items that were cleared, right?  Sadly not.  I often find that I hook into various event handlers in the OnCollectionChanged method.  In order to clear these subscriptions on reset it means that I have to hold a parallel collection of the items in the ObservableCollection.  Not good.</p>
<p>Also, why is there not an ObservableDictionary&#60;TKey, TValue&#62;?  Various people have attempted to implement this, but it should really be part of the framework and understood by data binding.</p>
<p>I&#8217;m hopeful that these issues will go away with the BCL changes for the very groovy System.Reactive framework.</p>
<p>&#60;/rant&#62;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[New Silverlight 3 / Blend 3 Video Tutorial - Working with Data]]></title>
<link>http://victorgaudioso.wordpress.com/2009/08/12/new-silverlight-3-blend-3-video-tutorial-working-with-data/</link>
<pubDate>Wed, 12 Aug 2009 03:06:43 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/08/12/new-silverlight-3-blend-3-video-tutorial-working-with-data/</guid>
<description><![CDATA[In this tutorial you will learn about: 1. Creating custom data objects 2. INotifyPropertyChanged 3. ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In this tutorial you will learn about:</p>
<p><em>1. Creating custom data objects<br />
2. INotifyPropertyChanged<br />
3. ObservableCollections<br />
4. Binding collections to a ListBox<br />
5. Editing a ListBox DataTemplate<br />
6. Importing a custom Panel<br />
7. Overriding the default panel of a ListBox<br />
8. Overriding the ItemsContainer of a ListBox<br />
9. Importing XML as a data source<br />
10. Creating a DataSource from an ObservableCollection</em></p>
<p><em><strong>URL:</strong> <a href="http://www.windowspresentationfoundation.com/WorkingWithDataInSL.wmv">http://www.windowspresentationfoundation.com/WorkingWithDataInSL.wmv</a></em></p>
<p><strong>EMAIL NOTIFICATION:</strong>To be notified of new tutorials, online workshops, articles, etc. by me email me at <a href="mailto:wpfauthor@gmail.com">wpfauthor@gmail.com</a>with the subject line &#8220;Silverlight Email List&#8221;</p>
<p><strong>TWITTER:</strong>To be notified of new tutorials, online workshops, articles, etc. by me follow me on Twitter.  Screename: victorgaudioso</p>
<p><strong>INSTANT MESSENGER:</strong>AOL: victoratrezn8 &#124; MSN: <a href="mailto:victor.gaudioso@identitymine.com">victor.gaudioso@identitymine.com</a> &#124; Yahoo!: victoratdeadline</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Silverlight 3 Behavior Tutorial Video Now Available!]]></title>
<link>http://victorgaudioso.wordpress.com/2009/08/07/silverlight-3-behavior-tutorial-video-now-available/</link>
<pubDate>Fri, 07 Aug 2009 22:34:30 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/08/07/silverlight-3-behavior-tutorial-video-now-available/</guid>
<description><![CDATA[In this tutorial I show you how to create a Silverlight 3 Behavior and then easily make use of it in]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In this tutorial I show you how to create a Silverlight 3 Behavior and then easily make use of it in Blend 3. <br />
<em> </em></p>
<p><em>This tutorial covers:<br />
</em>1. Creating a new Silverlight 3 project;<br />
2. Adding shapes to the artboard;<br />
3. Editing the project in Visual Studio;<br />
4. Creating a new class;<br />
5. Adding references to dll&#8217;s;<br />
6. Extending classes;<br />
7. Overriding abstract Methods;<br />
8. Creating Events and EventHandlers;<br />
9. Creating a custom DependencyProperty;<br />
10. Applying Behaviors in Blend 3;<br />
11. Setting Behvaior properties in Blend 3.</p>
<p><em>Difficulty</em>: 6 out of 10.</p>
<p><em>Duration</em>: About 20 minutes.</p>
<p><em>Who this is for: </em>Developers and designers wanting to learn how to create behaviors.</p>
<p><em>Video URL:</em> <a href="http://www.windowspresentationfoundation.com/Silverlight_BehaviorTutorial.wmv">http://www.windowspresentationfoundation.com/Silverlight_BehaviorTutorial.wmv</a></p>
<p><em>Source Code URL: <a href="http://www.windowspresentationfoundation.com/FillBehaviorSample_01.zip">http://www.windowspresentationfoundation.com/FillBehaviorSample_01.zip</a></em></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Obervable Collection Tutorial Made Easy]]></title>
<link>http://victorgaudioso.wordpress.com/2009/07/07/obervable-collection-tutorial-made-easy/</link>
<pubDate>Tue, 07 Jul 2009 09:47:19 +0000</pubDate>
<dc:creator>victorgaudioso</dc:creator>
<guid>http://victorgaudioso.wordpress.com/2009/07/07/obervable-collection-tutorial-made-easy/</guid>
<description><![CDATA[http://windowspresentationfoundation.com/Tutorials/ObservableCollectionBindingDataTemplate.html]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://windowspresentationfoundation.com/Tutorials/ObservableCollectionBindingDataTemplate.html">http://windowspresentationfoundation.com/Tutorials/ObservableCollectionBindingDataTemplate.html</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Databinding - Bindinglist,BindingSource and BusinessObjects - Part2]]></title>
<link>http://arindamsinha.wordpress.com/2009/06/28/databinding-bindinglistbindingsource-and-businessobjects-part2/</link>
<pubDate>Sun, 28 Jun 2009 07:45:19 +0000</pubDate>
<dc:creator>Arindam Sinha</dc:creator>
<guid>http://arindamsinha.wordpress.com/2009/06/28/databinding-bindinglistbindingsource-and-businessobjects-part2/</guid>
<description><![CDATA[I have posted another article in CodeProject. This is mainly focussing on the Searching and Sorting ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I have posted another <a title="Arindam's articles" href="http://www.codeproject.com/KB/grid/SearchSortBindingList.aspx" target="_blank">article </a>in <a title="Code Project" href="http://www.codeproject.com/" target="_blank">CodeProject</a>. This is mainly focussing on the Searching and Sorting of the BindingList.In general, these do not come in BindingList. This article would help you to understand how you can have Sorting and Searching in BindingList. I created a generic BindingList class and both the features are implemented. As we are use Business Entities and their collections in our applications, this generic BindingList would definitely reduce more coding stuff.</p>
<p>Please visit the following article -</p>
<p><a href="http://www.codeproject.com/KB/grid/SearchSortBindingList.aspx">http://www.codeproject.com/KB/grid/SearchSortBindingList.aspx</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Databinding - Bindinglist,BindingSource and BusinessObjects - Part1]]></title>
<link>http://arindamsinha.wordpress.com/2009/06/28/databinding-bindinglistbindingsource-and-businessobjects-part1/</link>
<pubDate>Sun, 28 Jun 2009 06:25:09 +0000</pubDate>
<dc:creator>Arindam Sinha</dc:creator>
<guid>http://arindamsinha.wordpress.com/2009/06/28/databinding-bindinglistbindingsource-and-businessobjects-part1/</guid>
<description><![CDATA[I have been working on a Windows application where .NET 3.5 has been used. In this application we we]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div class="mceTemp mceIEcenter">
<div class="mceTemp mceIEcenter" style="text-align:left;">
<p>I have been working on a Windows application where .NET 3.5 has been used. In this application we were supposed subscribe WebServices which are interacting through business objects. Some of the business objects are already defined as we were enhancing one existing application. Now I was supposed to find out an approach using which we can use databinding in UI layer. After browsing net, I decided to stick with <a title="BindingList" href="http://msdn.microsoft.com/en-us/library/ms132679.aspx" target="_blank">BindingList</a> and give few more flexibility to wrap this in a <a title="BindingSource" href="http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx" target="_blank">BindingSource</a>.</p>
<p>I would like to share one easy approach of dealing with BindingList and BindingSource. You can get the details in my <a title="Arindam's Article" href="http://www.codeproject.com/KB/grid/Bindinglist.aspx" target="_blank">article </a>posted in <a title="Code Project" href="http://www.codeproject.com" target="_blank">CodeProject</a>.</p>
<p><a href="http://www.codeproject.com/KB/grid/Bindinglist.aspx">http://www.codeproject.com/KB/grid/Bindinglist.aspx</a></div>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[WPF DataBinding using Visual Basic (VB.NET)]]></title>
<link>http://theludditedeveloper.wordpress.com/2009/06/16/wpf-databinding-using-visual-basic-vb-net/</link>
<pubDate>Tue, 16 Jun 2009 14:28:34 +0000</pubDate>
<dc:creator>theludditedeveloper</dc:creator>
<guid>http://theludditedeveloper.wordpress.com/2009/06/16/wpf-databinding-using-visual-basic-vb-net/</guid>
<description><![CDATA[Simple WPF DataBinding Example using xaml Box A Simple WPF DataBinding Example using code Box B WPF ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div id="attachment_103" class="wp-caption aligncenter" style="width: 457px"><a href="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050a.jpg"><img class="size-full wp-image-103" title="Simple WPF DataBinding Example using xaml Box A" src="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050a.jpg" alt="Simple WPF DataBinding Example using xaml Box A" width="447" height="140" /></a><p class="wp-caption-text">Simple WPF DataBinding Example using xaml Box A</p></div>
<div id="attachment_104" class="wp-caption aligncenter" style="width: 424px"><a href="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050b.jpg"><img class="size-full wp-image-104" title="Simple WPF DataBinding Example using code Box B" src="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050b.jpg" alt="Simple WPF DataBinding Example using code Box B" width="414" height="127" /></a><p class="wp-caption-text">Simple WPF DataBinding Example using code Box B</p></div>
<div id="attachment_105" class="wp-caption aligncenter" style="width: 328px"><a href="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050c.jpg"><img class="size-full wp-image-105" title="WPF DataBinding Example where UI updates during long running process Box C" src="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050c.jpg" alt="WPF DataBinding Example where UI updates during long running process Box C" width="318" height="78" /></a><p class="wp-caption-text">WPF DataBinding Example where UI updates during long running process Box C</p></div>
<div id="attachment_102" class="wp-caption aligncenter" style="width: 336px"><a href="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050d.jpg"><img class="size-full wp-image-102" title="WPF DataBinding Example where UI updates during long running process Box D" src="http://theludditedeveloper.wordpress.com/files/2009/06/snag-0050d.jpg" alt="WPF DataBinding Example where UI updates during long running process Box D" width="326" height="78" /></a><p class="wp-caption-text">WPF DataBinding Example where UI updates during long running process Box D</p></div>
<div class="mceTemp mceIEcenter" style="text-align:left;">Iwrote this article because of a problem I was having trying to get a label field to update during a long running process in a button handler.</div>
<div class="mceTemp mceIEcenter" style="text-align:left;">So first I went back to basics and got some simple WPF databinding examples to work in my Visual Basic application.</div>
<div class="mceTemp mceIEcenter" style="text-align:left;">For a good understanding I recommend articles written by Josh Smith, and you will see that my first two examples are very similar to Josh&#8217;s article <a href="http://www.codeproject.com/KB/WPF/MovingTowardWpfBinding.aspx" target="_self">Moving Toward WPF Data Binding One Step at a Time</a>. Josh is miles ahead of me when it comes to WPF so I would definitely recommend reading his articles if you really want to learn the ins and outs of WPF.</div>
<div class="mceTemp mceIEcenter" style="text-align:left;"> </div>
<div class="mceTemp mceIEcenter" style="text-align:left;">Box A and Box B simply update the textblock with the light blue background when the firstname and lastname are changed.  Box A uses xaml to perform the databinding and box B uses code to perform the databinding.</div>
<div class="mceTemp mceIEcenter" style="text-align:left;"> </div>
<div class="mceTemp mceIEcenter" style="text-align:left;">The problem that I have (and still have) is updating the status labels in boxes C and D.  I want to see the counter increment in the status label DURING execution not just at the end of the process.</div>
<div class="mceTemp mceIEcenter" style="text-align:left;"><span style="color:#0000ff;"><em>Late Update: Just found this article<span style="color:#800080;"> </span></em></span><a href="http://www.codeproject.com/KB/WPF/AsynchronousWPF.aspx" target="_self"><span style="color:#0000ff;"><em><span style="color:#800080;">Responsive UIs for WPF Applications Using Asynchronous Processing </span></em></span></a><span style="color:#0000ff;"><em>by johnsontroye on Codeplex, so I will check it out and post a new article if it works out.</em></span></div>
<div class="mceTemp mceIEcenter" style="text-align:left;"><span style="color:#0000ff;"><em> </em></span></div>
<div class="mceTemp mceIEcenter" style="text-align:left;"><span style="color:#0000ff;"><em>Please feel free to add comments if you have a solution.</em></span></div>
<div class="mceTemp mceIEcenter" style="text-align:left;"> </div>
<div class="mceTemp mceIEcenter" style="text-align:left;">Basically, when Button C or Button D is pressed the button handler will execute code as follows:</div>
<div class="mceTemp mceIEcenter" style="text-align:left;"> </div>
<div style="width:100%;height:400px;overflow:auto;">
<pre><code>
     Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnC.Click
        Dim i As Integer = 0
        For i = 0 To 99999
            lblBoxCupdate.Content = "Counter i = " + i.ToString
        Next
    End Sub

    Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnD.Click
        Dim i As Integer = 0
        Dim statusText As String = ""
        For i = 0 To 99999
            statusBoxD.statusText = "Counter i = " + i.ToString
            lblBoxDupdate.Focus()
            btnD.Focus()
        Next
    End Sub

</code></pre>
</div>
<p>The xaml code is as follows:</p>
<div style="width:100%;height:400px;overflow:auto;">
<pre><code>
&#60;Page x:Class="SimpleWPFDataBindingExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Name="SimpleWPFDataBindingExample"  WindowTitle="WPF Luddite Test Bed: Simple WPF DataBinding Example" Width="1024" Height="768"&#62;
    &#60;Grid ShowGridLines="True"&#62;
        &#60;Grid.RowDefinitions&#62;
            &#60;RowDefinition&#62;&#60;/RowDefinition&#62;
            &#60;RowDefinition&#62;&#60;/RowDefinition&#62;
        &#60;/Grid.RowDefinitions&#62;
        &#60;Grid.ColumnDefinitions&#62;
            &#60;ColumnDefinition&#62;&#60;/ColumnDefinition&#62;
            &#60;ColumnDefinition&#62;&#60;/ColumnDefinition&#62;
        &#60;/Grid.ColumnDefinitions&#62;
        &#60;StackPanel  x:Name="stackpanelBoxA" Grid.Row="0" Grid.Column="0"&#62;
            &#60;Label  Content="Box A: Row 0, Column 0" Margin="0 2 0 5"&#62;&#60;/Label&#62;
            &#60;TextBox x:Name="firstNameTextBox_A" Text="{Binding Path=FirstName, UpdateSourceTrigger=PropertyChanged}"  Width="200" Margin="0,4" /&#62;
            &#60;TextBox x:Name="lastNameTextBox_A" Text="{Binding Path=LastName, UpdateSourceTrigger=PropertyChanged}" Width="200" Margin="0,4" /&#62;
            &#60;TextBlock x:Name="fullNameTextBlock_A" Text="{Binding Path=FullName}" Width ="300" Background="LightBlue" Margin="0,4" /&#62;
        &#60;/StackPanel&#62;

        &#60;StackPanel x:Name="stackpanelBoxB" Grid.Row="0" Grid.Column="1"&#62;
            &#60;Label  Content="Box B: Row 0, Column 1" Margin="0 2 0 5"&#62;&#60;/Label&#62;
            &#60;TextBox x:Name="firstNameTextBox_B" Width="200" Margin="0,4" /&#62;
            &#60;TextBox x:Name="lastNameTextBox_B" Width="200" Margin="0,4" /&#62;
            &#60;TextBlock x:Name="fullNameTextBlock_B" Width ="300" Background="LightBlue" Margin="0,4" /&#62;
        &#60;/StackPanel&#62;

        &#60;StackPanel x:Name="stackpanelBoxC" Grid.Row="1" Grid.Column="0"&#62;
            &#60;Label  Content="Box C: Row 1, Column 0" Margin="0 2 0 5"&#62;&#60;/Label&#62;
            &#60;Button  x:Name="btnC" Height="23" Content="Button C" Width="75"&#62;&#60;/Button&#62;
            &#60;StackPanel Orientation="Horizontal" Margin="0 4"&#62;
                &#60;Label x:Name="lblBoxC"&#62;Status: &#60;/Label&#62;
                &#60;Label x:Name="lblBoxCupdate"&#62;&#60;/Label&#62;
            &#60;/StackPanel&#62;
        &#60;/StackPanel&#62;

        &#60;StackPanel x:Name="stackpanelBoxD" Grid.Row="1" Grid.Column="1"&#62;
            &#60;Label  Content="Box C: Row 1, Column 1" Margin="0 2 0 5"&#62;&#60;/Label&#62;
            &#60;Button  x:Name="btnD" Height="23" Content="Button D" Width="75"&#62;&#60;/Button&#62;
            &#60;StackPanel Orientation="Horizontal" Margin="0 4"&#62;
                &#60;Label x:Name="lblBoxD"&#62;Status:&#60;/Label&#62;
                &#60;Label x:Name="lblBoxDupdate" Content="{Binding Path=statusText, UpdateSourceTrigger=PropertyChanged}"&#62;&#60;/Label&#62;
            &#60;/StackPanel&#62;
        &#60;/StackPanel&#62;

    &#60;/Grid&#62;
&#60;/Page&#62;

</code></pre>
</div>
<p>The code behind is:</p>
<div style="width:100%;height:400px;overflow:auto;">
<pre><code>
Partial Public Class SimpleWPFDataBindingExample
    Private statusBoxD = New MyStatus
    Private Sub SimpleWPFDataBindingExample_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        '
        ' Set Up Bindings for Box A
        '
        Dim personBoxA = New Person()
        personBoxA.FirstName = "LudditeA"
        personBoxA.LastName = "DeveloperA"
        '
        Me.stackpanelBoxA.DataContext = personBoxA
        '
        ' Set Up Bindings for Box B
        '
        Dim person = New Person()
        person.FirstName = "Luddite"
        person.LastName = "Developer"
        '
        '   Set up DataBindings
        '
        Dim b As New Binding()
        b.Source = person
        b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
        b.Path = New PropertyPath("FirstName")
        Me.firstNameTextBox_B.SetBinding(TextBox.TextProperty, b)

        b = New Binding()
        b.Source = person
        b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
        b.Path = New PropertyPath("LastName")
        Me.lastNameTextBox_B.SetBinding(TextBox.TextProperty, b)

        b = New Binding()
        b.Source = person
        b.Path = New PropertyPath("FullName")
        Me.fullNameTextBlock_B.SetBinding(TextBlock.TextProperty, b)
        '
        ' Set Up initial value for Status in Box C.
        '
        lblBoxCupdate.Content = "Initial Status for Box C"
        '
        ' Set Up DataBindings for Box D and initial value for Status.
        '
        statusBoxD.statusText = "Initial Status for Box D"
        Me.stackpanelBoxD.DataContext = statusBoxD

    End Sub

    Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnC.Click
        Dim i As Integer = 0
        For i = 0 To 99999
            lblBoxCupdate.Content = "Counter i = " + i.ToString
        Next
    End Sub

    Private Sub btnD_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnD.Click
        Dim i As Integer = 0
        Dim statusText As String = ""
        For i = 0 To 99999
            statusBoxD.statusText = "Counter i = " + i.ToString
            lblBoxDupdate.Focus()
            btnD.Focus()
        Next
    End Sub
End Class

</code></pre>
</div>
<p>Classes used are:</p>
<div style="width:100%;height:400px;overflow:auto;">
<pre><code>
Imports System.ComponentModel
Imports System.Windows.Data
Public Class Person
    Implements INotifyPropertyChanged
    Private _FirstName As String
    Private _LastName As String

    ' Declare the PropertyChanged event
    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    '
    ' NotifyPropertyChanged will raise the PropertyChanged event passing the
    ' source property that is being updated.
    '
    Public Sub NotifyPropertyChanged(ByVal propertyName As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
    End Sub
    '
    Public Property FirstName() As String
        Get
            Return _FirstName
        End Get
        Set(ByVal value As String)
            _FirstName = value
            '
            ' Call NotifyPropertyChanged when the property is updated
            '
            NotifyPropertyChanged("FirstName")
            NotifyPropertyChanged("FullName")
        End Set
    End Property

    Public Property LastName() As String
        Get
            Return _LastName
        End Get
        Set(ByVal value As String)
            _LastName = value
            '
            ' Call NotifyPropertyChanged when the property is updated
            '
            NotifyPropertyChanged("LastName")
            NotifyPropertyChanged("FullName")
        End Set
    End Property

    Public ReadOnly Property FullName() As String
        Get
            Return [String].Format("{0}, {1}", Me.LastName, Me.FirstName)
        End Get
    End Property

End Class

Public Class MyStatus
    Implements INotifyPropertyChanged
    Private _statusText As String
    ' Declare the PropertyChanged event
    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    '
    ' NotifyPropertyChanged will raise the PropertyChanged event passing the
    ' source property that is being updated.
    '
    Public Sub NotifyPropertyChanged(ByVal propertyName As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
    End Sub
    Public Property statusText() As String
        Get
            Return _statusText
        End Get
        Set(ByVal value As String)
            _statusText = value
            '
            ' Call NotifyPropertyChanged when the property is updated
            '
            NotifyPropertyChanged("statusText")
        End Set
    End Property
End Class

</code></pre>
</div>
<p>Application Resources are as follows:</p>
<div style="width:100%;height:400px;overflow:auto;">
<pre><code>
&#60;Application x:Class="Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainMenu.xaml"&#62;
    &#60;Application.Resources&#62;
        &#60;Style x:Key="ButtonStyle240x24"&#62;
            &#60;Setter Property="Button.Height" Value="24"/&#62;
            &#60;Setter Property="Button.Width" Value="240"/&#62;
            &#60;Setter Property="Button.VerticalAlignment" Value="Center"/&#62;
            &#60;Setter Property="Button.Background" Value="Black"/&#62;
            &#60;Setter Property="Button.Foreground" Value="White"/&#62;
            &#60;Setter Property="Button.FontSize" Value="14"/&#62;
            &#60;Setter Property="Button.FontFamily" Value="Verdana"/&#62;
            &#60;Setter Property="Button.Margin" Value = "2,0,3,0"/&#62;
        &#60;/Style&#62;
        &#60;Style x:Key="ButtonStyle850x24"&#62;
            &#60;Setter Property="Button.Height" Value="24"/&#62;
            &#60;Setter Property="Button.Width" Value="850"/&#62;
            &#60;Setter Property="Button.VerticalAlignment" Value="Center"/&#62;
            &#60;Setter Property="Button.Background" Value="Black"/&#62;
            &#60;Setter Property="Button.Foreground" Value="White"/&#62;
            &#60;Setter Property="Button.FontSize" Value="14"/&#62;
            &#60;Setter Property="Button.FontFamily" Value="Verdana"/&#62;
            &#60;Setter Property="Button.Margin" Value = "2,0,3,0"/&#62;
        &#60;/Style&#62;

        &#60;Style TargetType="{x:Type ListBoxItem}"&#62;
            &#60;Style.Triggers&#62;
                &#60;Trigger Property="ListBox.AlternationIndex" Value="1"&#62;
                    &#60;Setter Property="Background" Value="LightBlue"/&#62;
                &#60;/Trigger&#62;
            &#60;/Style.Triggers&#62;
        &#60;/Style&#62;
    &#60;/Application.Resources&#62;
&#60;/Application&#62;

</code></pre>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Tooltips for indivual cells of a DataGrid]]></title>
<link>http://kiefermat.wordpress.com/2009/06/15/tooltips-for-indivual-cells-of-a-datagrid/</link>
<pubDate>Mon, 15 Jun 2009 12:50:21 +0000</pubDate>
<dc:creator>mkiefer</dc:creator>
<guid>http://kiefermat.wordpress.com/2009/06/15/tooltips-for-indivual-cells-of-a-datagrid/</guid>
<description><![CDATA[Just recently,  I have been faced with the question on how to add cell dependent tooltips to individ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Just recently,  I have been faced with the question on how to add cell dependent tooltips to individual cells of a DataGrid in Silverlight. If you generate the columns by yourself, the task is straight forward by using the appropriate data template for the cell. Something like this:</p>
<pre class="brush: xml;">
&lt;Data:DataGrid&gt;
   &lt;Data:DataGrid.Columns&gt;
      &lt;Data:DataGridTemplateColumn&gt;
         &lt;Data:DataGridTemplateColumn.CellTemplate&gt;
            &lt;DataTemplate&gt;
               &lt;TextBlock  Text=&quot;{Binding ColumnProperty}&quot;
                    ToolTipService.ToolTip=&quot;{Binding ColumnProperty}&quot;/&gt;
            &lt;/DataTemplate&gt;
         &lt;/Data:DataGridTemplateColumn.CellTemplate&gt;
      &lt;/Data:DataGridTemplateColumn&gt;
   &lt;/Data:DataGrid.Columns&gt;
&lt;/Data:DataGrid&gt;
</pre>
<p>However, if you let the columns be autogenerated by the grid, things are not so straight forward anymore. <!--more-->One solution which should work in many cases could be to customize or replace a column once it is generated by handling the DataGrid.AutoGeneratedColumn event. This solution is described in detail on <a href="http://msdn.microsoft.com/en-us/library/cc903950(VS.95).aspx">MSDN</a>.</p>
<p>A better fitting solution for my problem was to handle the DataGrid.LoadingRow event like this:</p>
<pre class="brush: csharp;">
private void resultSetGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
   DataGrid dataGrid = sender as DataGrid;
   foreach (DataGridColumn column in dataGrid.Columns)
   {
      string cellValue = GetCellValue(e.Row, column.Header as string);

      if (cellValue != null)
      {
         FrameworkElement element = column.GetCellContent(e.Row);
         ToolTipService.SetToolTip(element, new ToolTipCtrl(cellValue));
      }
   }
}
</pre>
<p>In GetCellValue you can e.g. use reflection to get the value of the property named like the column header, which should always work with autogenerated columns if you did not change the header of the column by yourself.</p>
<pre class="brush: csharp;">
private static string GetCellValue(DataGridRow row, string propertyName)
{
   string value = null;
   object boundObject = row.DataContext;

   if (boundObject != null)
   {
        Type type = boundObject.GetType();
        value = type.InvokeMember(propertyName, BindingFlags.GetProperty,
                           null, boundObject, new object[] { }) as string;
   }

   return value;
}
</pre>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:0;width:1px;height:1px;">and easy by using a cell template similar to this one:</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MVVM Part 4: Commanding]]></title>
<link>http://winsharp93.wordpress.com/2009/06/13/my-interpretation-of-model-view-viewmodel-mvvm-part-4-of-n-commanding/</link>
<pubDate>Sat, 13 Jun 2009 15:52:08 +0000</pubDate>
<dc:creator>winsharp93</dc:creator>
<guid>http://winsharp93.wordpress.com/2009/06/13/my-interpretation-of-model-view-viewmodel-mvvm-part-4-of-n-commanding/</guid>
<description><![CDATA[Note: This posting is part of a series. See MVVM-Library for other parts and download. Commanding is]]></description>
<content:encoded><![CDATA[Note: This posting is part of a series. See MVVM-Library for other parts and download. Commanding is]]></content:encoded>
</item>
<item>
<title><![CDATA[MVVM Part 3: ViewModelBase]]></title>
<link>http://winsharp93.wordpress.com/2009/06/11/my-interpretation-of-model-view-viewmodel-mvvm-part-3-of-n-viewmodelbase/</link>
<pubDate>Thu, 11 Jun 2009 11:04:34 +0000</pubDate>
<dc:creator>winsharp93</dc:creator>
<guid>http://winsharp93.wordpress.com/2009/06/11/my-interpretation-of-model-view-viewmodel-mvvm-part-3-of-n-viewmodelbase/</guid>
<description><![CDATA[Note: This posting is part of a series. See MVVM-Library for other parts and download. It’s time for]]></description>
<content:encoded><![CDATA[Note: This posting is part of a series. See MVVM-Library for other parts and download. It’s time for]]></content:encoded>
</item>
<item>
<title><![CDATA[Change a Dependency Property in the setter of a bound property]]></title>
<link>http://winsharp93.wordpress.com/2009/06/10/change-a-dependency-property-in-the-setter-of-a-bound-property/</link>
<pubDate>Wed, 10 Jun 2009 20:10:24 +0000</pubDate>
<dc:creator>winsharp93</dc:creator>
<guid>http://winsharp93.wordpress.com/2009/06/10/change-a-dependency-property-in-the-setter-of-a-bound-property/</guid>
<description><![CDATA[Quite a confusing title, but here is an example where this can be interesting (Note: I’m mot using m]]></description>
<content:encoded><![CDATA[Quite a confusing title, but here is an example where this can be interesting (Note: I’m mot using m]]></content:encoded>
</item>

</channel>
</rss>
