<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eclipsed4utoo&#039;s Blog&#187; blend</title>
	<atom:link href="http://eclipsed4utoo.com/blog/tag/blend/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsed4utoo.com/blog</link>
	<description>Not Your Ordinary Programmer</description>
	<lastBuildDate>Thu, 08 Sep 2011 17:09:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Silverlight 4 &#8211; Sample Data with Blend 4</title>
		<link>http://eclipsed4utoo.com/blog/silverlight-4-sample-data-blend-4/</link>
		<comments>http://eclipsed4utoo.com/blog/silverlight-4-sample-data-blend-4/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 23:00:45 +0000</pubDate>
		<dc:creator>Ryan Alford</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[blend]]></category>
		<category><![CDATA[blend 4]]></category>
		<category><![CDATA[expression]]></category>
		<category><![CDATA[Silverlight 4]]></category>

		<guid isPermaLink="false">http://eclipsed4utoo.com/blog/?p=496</guid>
		<description><![CDATA[In a previous tutorial, I showed how to do a custom Item Template for a ListBox. However, one of the painstaking parts of that was having to create the class and the code to populate the ListBox with actual data. Also, even though I was populating the ListBox, I still simply saw blank controls during [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a title="Silverlight – Custom ListBox Item Template" href="http://eclipsed4utoo.com/blog/silverlightwpf-custom-listbox-item-template/" target="_blank">previous tutorial</a>, I showed how to do a custom Item Template for a ListBox. However, one of the painstaking parts of that was having to create the class and the code to populate the ListBox with actual data. Also, even though I was populating the ListBox, I still simply saw blank controls during design-time.</p>
<p>This is where Sample Data comes in. Not only can you quickly create sample data for a control, you can drag and drop it onto the control, and the ItemTemplate will be created for you(which you can still edit). And the biggest plus to using Sample Data?&#8230;.the data can be view at DESIGN-TIME.</p>
<p>So first, let&#8217;s create a Silverlight project in Blend. I named mine <strong>SampleDataProject</strong>.</p>
<p><img class="alignnone size-full wp-image-497" title="10-24-2010 9-43-51 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-9-43-51-AM.png" alt="10-24-2010 9-43-51 AM" width="308" height="283" /></p>
<p>Next, we will put a <strong>ListBox </strong>on our page, and give it a <strong>Height </strong>of <strong>200 </strong>and a <strong>Width </strong>of <strong>250</strong>.</p>
<pre class="brush: csharp;">
&lt;ListBox
	Margin=&quot;178,128,212,152&quot;
	Width=&quot;250&quot;
	Height=&quot;200&quot;/&gt;
</pre>
<p>Now that we have the ListBox on the page, we can create our Sample Data. Click on the <strong>Data </strong>window, then on the<strong> &#8220;Create sample data&#8221;</strong> button, then choose <strong>&#8220;New Sample Data&#8230;&#8221;</strong>&#8230;</p>
<p><img class="alignnone size-full wp-image-498" title="10-24-2010 9-47-27 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-9-47-27-AM.png" alt="10-24-2010 9-47-27 AM" width="238" height="146" /></p>
<p>We are going to name it <strong>PersonDataSource</strong>.</p>
<p><img class="alignnone size-full wp-image-499" title="10-24-2010 9-49-06 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-9-49-06-AM.png" alt="10-24-2010 9-49-06 AM" width="363" height="176" /></p>
<p>A couple of things to note on this screen. You will see two radio buttons: Project, and This document. If you choose Project, it will make the sample data available to any control in the project. If you choose This document, then the sample data will only be available to this page.</p>
<p>You will also see a checkbox on this screen saying &#8220;Enable sample data when application is running&#8221;. This allows you to use the sample data in design time, but use another data source during runtime. Uncheck this box if you want to use a different data source at runtime. Since we want our sample data for design time and runtime, we will leave it checked.</p>
<p>After creating the sample data, the Data window will now show our data in a treeview type layout. By default, it will add two properties for us.</p>
<p>Let&#8217;s change the first property by double clicking it and giving it the name <strong>FullName</strong>.</p>
<p>Let&#8217;s change the second property to <strong>Age</strong>. By default, this property is set to a boolean type. Since our age is not a boolean value, we need to change that to a numeric format. Click on the <strong>&#8220;Change property type&#8221;</strong> button on the far right of the property line. You will see a dropdown with different types. Choose <strong>&#8220;Number&#8221;</strong>. We will leave it&#8217;s <strong>length </strong>at <strong>2</strong>.</p>
<p><img class="alignnone size-full wp-image-500" title="10-24-2010 9-55-17 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-9-55-17-AM.png" alt="10-24-2010 9-55-17 AM" width="232" height="198" /></p>
<p>Now that we have the properties setup, we need to add some actual data. Click on the <strong>&#8220;Edit sample values&#8221;</strong> button&#8230;</p>
<p><img class="alignnone size-full wp-image-501" title="10-24-2010 9-58-49 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-9-58-49-AM.png" alt="10-24-2010 9-58-49 AM" width="229" height="199" /></p>
<p>You will now see a window with a number of rows and data. At the bottom, you can determine how many rows you want to show. We are going to change this to <strong>3</strong>. We are going to add some data to those rows, then click <strong>OK</strong>.</p>
<p><img class="alignnone size-full wp-image-502" title="10-24-2010 10-00-41 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-10-00-41-AM.png" alt="10-24-2010 10-00-41 AM" width="478" height="326" /></p>
<p>Now that we have our sample data setup, let&#8217;s simply drag and drop the &#8220;Collection&#8221; from the Data window onto the ListBox. The ListBox will create it&#8217;s own ItemTemplate to display the data.</p>
<p>That&#8217;s all you have to do. As you can see, we now have data in our ListBox while designing it&#8230;</p>
<p><img class="alignnone size-full wp-image-503" title="10-24-2010 10-11-16 AM" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/10/10-24-2010-10-11-16-AM.png" alt="10-24-2010 10-11-16 AM" width="429" height="350" /></p>
<p>You can look at my other tutorial on how to edit the created ItemTemplate to show the data different ways.</p>
<p>To me, this is one of the best features of Blend. Being able to see how a collection control will look at design time will speed up the development process. No longer will you have to continuously run the application to see if you have the layout correct.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsed4utoo.com/blog/silverlight-4-sample-data-blend-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight 4 &#8211; Creating a Custom Modal Dialog</title>
		<link>http://eclipsed4utoo.com/blog/silverlight-4-creating-custom-modal-dialog/</link>
		<comments>http://eclipsed4utoo.com/blog/silverlight-4-creating-custom-modal-dialog/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 06:30:26 +0000</pubDate>
		<dc:creator>Ryan Alford</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[blend]]></category>
		<category><![CDATA[modal dialog]]></category>
		<category><![CDATA[Silverlight 4]]></category>

		<guid isPermaLink="false">http://eclipsed4utoo.com/blog/?p=380</guid>
		<description><![CDATA[For a Silverlight application I did recently, I wanted to do a custom modal dialog box for showing informational messages, error messages, or other messages to the user.  This dialog box would have no title bar or &#8220;X&#8221; button, and would have rounded corners. For this tutorial, we will use Blend 4 to accomplish our [...]]]></description>
			<content:encoded><![CDATA[<p>For a Silverlight application I did recently, I wanted to do a custom modal dialog box for showing informational messages, error messages, or other messages to the user.  This dialog box would have no title bar or &#8220;X&#8221; button, and would have rounded corners.</p>
<p>For this tutorial, we will use Blend 4 to accomplish our task.</p>
<p>First, create a new Silverlight 4 application.  I named mine <strong>CustomDialog</strong>.</p>
<p><img class="alignnone size-full wp-image-381" title="Image1" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image1.png" alt="Image1" width="548" height="468" /></p>
<p>Once the project has been created, we are going to add a new item to our Silverlight project.  This item will be a <strong>ChildWindow</strong>.  I named mine <strong>DialogPopup</strong>.</p>
<p><img class="alignnone size-full wp-image-382" title="Image2" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image2.png" alt="Image2" width="390" height="427" /></p>
<p>The <strong>ChildWindow </strong>will handle the modal dialog part of our window.  However, there are parts of the <strong>ChildWindow </strong>that I didn&#8217;t like and wanted to remove/change, such as the window chrome.  I also wanted to round the corners of the window.   To do this, we need to edit the template for the window.  In the <strong>Objects and Timeline</strong> window, right-click on the <strong>ChildWindow </strong>parent &#8211;&gt; <strong>Edit Template</strong> &#8211;&gt; <strong>Edit a Copy</strong>&#8230;</p>
<p><img class="alignnone size-full wp-image-383" title="Image3" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image3.png" alt="Image3" width="457" height="495" /></p>
<p>We are going to keep it simple and save the new style to the ChildWindow document.</p>
<p><img class="alignnone size-full wp-image-384" title="Image4" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image4.png" alt="Image4" width="459" height="249" /></p>
<p>So first, we are just going to delete the window chrome from the window.  The window chrome is the title bar and the &#8220;X&#8221; used to close the window.  Drill-down in the treeview until you find the <strong>Chrome </strong>entry.  Right-click, and choose <strong>Delete</strong>.</p>
<p><img class="alignnone size-full wp-image-385" title="Image5" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image5.png" alt="Image5" width="437" height="391" /></p>
<p>Next, we need to delete some of the Borders.  These give the window a grey border that I didn&#8217;t want.</p>
<p><img class="alignnone size-full wp-image-402" title="Image11" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image11.png" alt="Image11" width="431" height="373" /></p>
<p>Next, we are going to round the corners of the window.  Drill-down and click on the <strong>Border </strong>shown below.</p>
<p><img class="alignnone size-full wp-image-405" title="Image12" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image12.png" alt="Image12" width="290" height="244" /></p>
<p>In the <strong>Properties </strong>window, set the <strong>CornerRadius </strong>to <strong>20</strong>.</p>
<p><img class="alignnone size-full wp-image-387" title="Image7" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image7.png" alt="Image7" width="275" height="192" /></p>
<p>Move down to the next <strong>Border</strong>,</p>
<p><img class="alignnone size-full wp-image-406" title="Image13" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image13.png" alt="Image13" width="302" height="249" /></p>
<p>And set it&#8217;s <strong>CornerRadius </strong>to <strong>20</strong>.</p>
<p><img class="alignnone size-full wp-image-389" title="Image9" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image9.png" alt="Image9" width="271" height="177" /></p>
<p>With the same <strong>Border </strong>selected, in the Properties window, set the <strong>Background Brush</strong> to a color of your choice.</p>
<p><img class="alignnone size-full wp-image-390" title="Image10" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image10.png" alt="Image10" width="270" height="391" /></p>
<p>The window &#8220;jazz&#8221; is now complete.  Next, we are going to move to the XAML.</p>
<p>First, we need to give our window a name so we can handle binding.  I named mine <strong>myCustomPopup</strong>.</p>
<pre class="brush: xml;">
&lt;sdk:ChildWindow
   xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
   xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
   xmlns:sdk=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk&quot;
   x:Class=&quot;CustomDialog.DialogPopup&quot;
   x:Name=&quot;myCustomPopup&quot;
   Title=&quot;DialogPopup&quot;
   Width=&quot;400&quot; Height=&quot;300&quot;&gt;
</pre>
<p>Now we need to add a <strong>TextBlock </strong>to the window to hold our message.</p>
<pre class="brush: xml;">
&lt;TextBlock
    Text=&quot;{Binding Message, ElementName=myCustomPopup}&quot;
    Margin=&quot;51,88,57,113&quot;
    TextWrapping=&quot;Wrap&quot;
    Foreground=&quot;#FF1D1515&quot;
    FontWeight=&quot;Bold&quot;
    TextAlignment=&quot;Center&quot;/&gt;
</pre>
<p>You may notice that we are binding to a property called <strong>Message</strong>.  This is a custom <strong>DependencyProperty </strong>that will correspond to a public property that we will set when we create an instance of the window.</p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// Creates a public property for the TextBlock to bind to
/// &lt;/summary&gt;
public static DependencyProperty MessageProperty = DependencyProperty.Register(&quot;Message&quot;, typeof(string), typeof(DialogPopup), new PropertyMetadata(&quot;&quot;));
public string Message
{
     get { return (string)GetValue(MessageProperty); }
     set { SetValue(MessageProperty, value); }
}
</pre>
<p>This will complete our work for the window.  To show off the new window, lets add a <strong>Button </strong>to the <strong>MainPage.xaml</strong>, create an <strong>EventHandler </strong>for the <strong>Click </strong>event.</p>
<pre class="brush: xml;">
&lt;Grid
   x:Name=&quot;LayoutRoot&quot;
   Background=&quot;White&quot;&gt;

     &lt;Button
        x:Name=&quot;btnShowMessage&quot;
        Content=&quot;Click Me&quot;
        Click=&quot;btnShowMessage_Click&quot;
        Margin=&quot;251,207,289,236&quot;  /&gt;
&lt;/Grid&gt;
</pre>
<p>And the code for the <strong>Click </strong>event&#8230;</p>
<pre class="brush: csharp;">
private void btnShowMessage_Click(object sender, System.Windows.RoutedEventArgs e)
{
     DialogPopup dialog = new DialogPopup();
     dialog.Message = &quot;Our message&quot;;
     dialog.Show();
}
</pre>
<p>And that will complete our tutorial.  Run the application from Blend using <strong>F5</strong>, and you should see this..</p>
<p><img class="alignnone size-full wp-image-408" title="Image14" src="http://eclipsed4utoo.com/blog/wp-content/uploads/2010/07/Image14.png" alt="Image14" width="489" height="364" /></p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsed4utoo.com/blog/silverlight-4-creating-custom-modal-dialog/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

