<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Sharker Khaleed Mahmud Silverlight Tips &#38; Tricks</title>
	<atom:link href="http://silverlightips.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://silverlightips.net</link>
	<description>Either write something worth reading or do something worth writing</description>
	<lastBuildDate>Wed, 14 Dec 2011 01:17:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='silverlightips.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/638032b2d3438c2f6232a98d03f65c10?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Sharker Khaleed Mahmud Silverlight Tips &#38; Tricks</title>
		<link>http://silverlightips.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://silverlightips.net/osd.xml" title="Sharker Khaleed Mahmud Silverlight Tips &#38; Tricks" />
	<atom:link rel='hub' href='http://silverlightips.net/?pushpress=hub'/>
		<item>
		<title>94. Using the Bing API in Silverlight</title>
		<link>http://silverlightips.net/2011/01/09/bing-search-api-silverlight/</link>
		<comments>http://silverlightips.net/2011/01/09/bing-search-api-silverlight/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 02:22:06 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[silverlight bing search]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1285</guid>
		<description><![CDATA[The Version 2 of Bing API has cross domain policy&#8230;so now it can easily do Bing Search from silverlight app. In this entry, I will do a simple query search using the API applying MVVM pattern and ICommand. You can see the live example here [live demo] The SOURCE CODE(.zip) is at the end of the page for download. Let look at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1285&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1285" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2011%2F01%2F09%2Fbing-search-api-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-kJ%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2011%2F01%2F09%2Fbing-search-api-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2011/01/bingsearch1.png"><img class="alignnone size-full wp-image-1290" title="BingSearch" src="http://shamrat231.files.wordpress.com/2011/01/bingsearch1.png" alt="" width="705" height="238" /></a><a href="http://shamrat231.files.wordpress.com/2011/01/bingsearch.png"></a></p>
<p>The Version 2 of Bing API has cross domain policy&#8230;so now it can easily do Bing Search from silverlight app. In this entry, I will do a simple query search using the API applying MVVM pattern and ICommand.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t94/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>Let look at the initial code</p>
<p>        public void Search(string query, ActionXElement&gt;&gt; searchCallBack)<br />
        {<br />
            string AppId = &#8220;&#8212;&#8221;; //API for http:// silverlightips.net site<br />
            string _baseURI  = &#8220;<a href="http://api.search.live.net/xml.aspx?Appid={0}&amp;query={1}&amp;sources=web">http://api.search.live.net/xml.aspx?Appid={0}&amp;query={1}&amp;sources=web</a>&#8220;;</p>
<p>            Uri address = new Uri(String.Format(_baseURI, AppId, query));</p>
<p>            WebClient service = new WebClient();<br />
            service.OpenReadCompleted += (sender, e) =&gt; searchCallBack(GetResults(e));<br />
            service.OpenReadAsync(address);<br />
        }</p>
<p>As you can see I created a simple URI to do a API search. In here, the parameter that i am passing are appid, query text and the sources in the base uri. Just to give u the idea of the URI that is being created, i will debug it and put a snapshot below.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/p1.png"><img class="alignnone size-full wp-image-1288" title="p1" src="http://shamrat231.files.wordpress.com/2011/01/p1.png" alt="" width="944" height="49" /></a></p>
<p>Copy the url and test paste it in the browser to check if the url works or not. Do note that our e.result should return exactly the same output as shown in the browser.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/p2.png"><img class="alignnone size-full wp-image-1292" title="p2" src="http://shamrat231.files.wordpress.com/2011/01/p2.png" alt="" width="737" height="380" /></a></p>
<p>Our webclient should return exactly this. If you look in the above code, we are calling a method GetResults where we are returning the results as shown below.</p>
<p>        private XElement GetResults(OpenReadCompletedEventArgs e)<br />
        {<br />
            XElement element = null;</p>
<p>            if (e.Error == null)<br />
            {<br />
                if (e.Result != null)<br />
                {<br />
                    element = XElement.Load(XmlReader.Create(e.Result));<br />
                }<br />
            }</p>
<p>            return element;<br />
        }</p>
<p>The above code returns the search result. The type of result that it give is stream type. To do LINQ queries on XML, I converted the result to XElement. So, the converted XElement result should be equivalent to the one the url I pasted before. Let debug and check it.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/p3.png"><img class="alignnone size-full wp-image-1293" title="p3" src="http://shamrat231.files.wordpress.com/2011/01/p3.png" alt="" width="642" height="294" /></a></p>
<p>So we basically can see the result that it gives. So we can conclude the WebService part of the project is working. The web service is being invoked through a view model through an interface.</p>
<p><span style="text-decoration:underline;">BingAPIViewModel.cs</span></p>
<p>    public class BingAPIViewModel<br />
    {<br />
        public ObservableCollection&lt;SearchResult&gt; Results { get; set; }<br />
        public IAPIService APIService { get; set; }</p>
<p>        public BingAPIViewModel()<br />
        {<br />
            this.Results = new ObservableCollection&lt;SearchResult&gt;();<br />
            this.APIService = new APIService();<br />
            this.APIService.Search(&#8220;cricket&#8221;, this.OnSearchCompleted);<br />
        }</p>
<p>        private void OnSearchCompleted(XElement searchResults)<br />
        {<br />
            this.Results.Clear();<br />
        }<br />
    }</p>
<p>Here the return type is XElement which is great for LINQ queries. Now lets create a simple Model for the return collection.</p>
<p>    public class SearchResult<br />
    {<br />
        public string Title { get; set; }<br />
        public string Description { get; set; }<br />
        public string UrL { get; set; }<br />
    }</p>
<p>The main idea is now to iterate our collection of XElement and fill our Results of type Observablecollection which is done below.</p>
<p>        private void OnSearchCompleted(XElement elements)<br />
        {<br />
            this.Results.Clear();<br />
            const string WEB_NS = &#8220;<a href="http://schemas.microsoft.com/LiveSearch/2008/04/XML/web">http://schemas.microsoft.com/LiveSearch/2008/04/XML/web</a>&#8220;;<br />
            IEnumerable&lt;XNode&gt; nodes = null;<br />
            nodes = elements.Descendants(XName.Get(&#8220;Results&#8221;, WEB_NS)).Nodes();</p>
<p>            if (nodes.Count() &gt; 0)<br />
            {<br />
                var results = from uris in nodes<br />
                              select new SearchResult<br />
                              {<br />
                                  UrL = ((XElement)uris).Element(XName.Get(&#8220;Url&#8221;, WEB_NS)).Value,<br />
                                  Title = ((XElement)uris).Element(XName.Get(&#8220;Title&#8221;, WEB_NS)).Value,<br />
                                  Description = ((XElement)uris).Element(XName.Get(&#8220;Description&#8221;, WEB_NS)).Value,<br />
                              };</p>
<p>                foreach (SearchResult result in results)<br />
                {<br />
                    Results.Add(result);<br />
                }<br />
            }<br />
        }</p>
<p>Ok, we have received the search result into our view model. Now if we bind the view model to our view we can see the data. This can be easily done by this.</p>
<p>this.DataContext = new BingAPIViewModel(); at code and in UI</p>
<p>            &lt;ListBox x:Name=&#8221;BingSearch&#8221; ItemsSource=&#8221;{Binding Results}&#8221; Style=&#8221;{Binding ListBoxStyle}&#8221;&gt;<br />
            &lt;ListBox.ItemTemplate&gt;<br />
                &lt;DataTemplate&gt;<br />
                    &lt;StackPanel&gt;<br />
                        &lt;HyperlinkButton Content=&#8221;{Binding Title}&#8221; NavigateUri=&#8221;{Binding Url}&#8221; TargetName=&#8221;blank&#8221; Height=&#8221;20&#8243;/&gt;<br />
                        &lt;TextBlock Text=&#8221;{Binding Description}&#8221; HorizontalAlignment=&#8221;Stretch&#8221; TextWrapping=&#8221;Wrap&#8221; Width=&#8221;500&#8243;  /&gt;<br />
                    &lt;/StackPanel&gt;<br />
                &lt;/DataTemplate&gt;<br />
            &lt;/ListBox.ItemTemplate&gt;<br />
        &lt;/ListBox&gt;</p>
<p>So far, we have used fixed variable for our query search. Now lets make it dynamic. For this I will use simple ICommand. Bind the button with an ICommand in view model.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/p4.png"><img class="alignnone size-full wp-image-1294" title="p4" src="http://shamrat231.files.wordpress.com/2011/01/p4.png" alt="" width="626" height="50" /></a></p>
<p>and the modified view model using ICommand </p>
<p>       public ICommand SearchCommand { get; set; }<br />
        public IAPIService APIService { get; set; }<br />
        private const string WEB_NS = &#8220;<a href="http://schemas.microsoft.com/LiveSearch/2008/04/XML/web">http://schemas.microsoft.com/LiveSearch/2008/04/XML/web</a>&#8220;;</p>
<p>        public BingAPIViewModel()<br />
        {<br />
            this.Results = new ObservableCollection&lt;SearchResult&gt;();<br />
            this.APIService = new APIService();<br />
            this.SearchCommand = new DelegateCommand(this.SearchCommandChanged, this.CanInputTexChanged);<br />
            this.APIService.Search(&#8220;sample&#8221;, this.OnSearchCompleted);<br />
        }</p>
<p>        internal bool CanInputTexChanged(object param)<br />
        {<br />
            return true;<br />
        }</p>
<p>        private void SearchCommandChanged(object param)<br />
        {<br />
            this.APIService.Search(param as string, this.OnSearchCompleted);<br />
        }</p>
<p>As always, you can download the source code from here <a title="silverlight download link" href="http://www.megaupload.com/?d=856VNEIO" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/silverlight-bing-search/'>silverlight bing search</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1285/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1285&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2011/01/09/bing-search-api-silverlight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/bingsearch1.png" medium="image">
			<media:title type="html">BingSearch</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/p1.png" medium="image">
			<media:title type="html">p1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/p2.png" medium="image">
			<media:title type="html">p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/p3.png" medium="image">
			<media:title type="html">p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/p4.png" medium="image">
			<media:title type="html">p4</media:title>
		</media:content>
	</item>
		<item>
		<title>93. Animated Vertical Scrollable Content in Silverlight</title>
		<link>http://silverlightips.net/2011/01/01/animated-vertical-scrollable-content/</link>
		<comments>http://silverlightips.net/2011/01/01/animated-vertical-scrollable-content/#comments</comments>
		<pubDate>Sat, 01 Jan 2011 21:52:38 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[photo gallery]]></category>
		<category><![CDATA[scrolling animation]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1272</guid>
		<description><![CDATA[In this entry, I will create a simple animated vertical sliding content. To do this I will start first by creating a simple listbox and then do the binding using MVVM pattern and afterwards apply animation to the listboxitem content from code behind. You can see the live example here [live demo] The SOURCE CODE(.zip) is at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1272&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1272" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2011%2F01%2F01%2Fanimated-vertical-scrollable-content%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-kw%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2011%2F01%2F01%2Fanimated-vertical-scrollable-content%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2011/01/pic0.png"><img class="alignnone size-full wp-image-1273" title="pic0" src="http://shamrat231.files.wordpress.com/2011/01/pic0.png" alt="" width="470" height="414" /></a></p>
<p>In this entry, I will create a simple animated vertical sliding content. To do this I will start first by creating a simple listbox and then do the binding using MVVM pattern and afterwards apply animation to the listboxitem content from code behind.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t93/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>So lets look at the initial listbox code.</p>
<p>        &lt;ListBox ItemsSource=&#8221;{Binding Items}&#8221;&gt;<br />
            &lt;ListBox.ItemTemplate&gt;<br />
                &lt;DataTemplate&gt;<br />
                    &lt;StackPanel&gt;<br />
                        &lt;Image Source=&#8221;Images/unknown.png&#8221; Height=&#8221;100&#8243; /&gt;<br />
                        &lt;TextBlock Text=&#8221;this is Content&#8221; /&gt;<br />
                    StackPanel&gt;<br />
                &lt;/DataTemplate&gt;<br />
            &lt;/ListBox.ItemTemplate&gt;<br />
        &lt;/ListBox&gt;</p>
<p>It basically is a simple data structure but works, now the data need to be binded to a collection. In this case the collection is items eg. ItemsSource=&#8221;{Binding Items}&#8221;.  In my case, I am going to create a simple view model with this property and bind the view model to the user control i.e views. This can be easily achieved by setting like this.</p>
<p>MainPage.xaml.cs<br />
        public MainPage()<br />
        {<br />
            InitializeComponent();<br />
            this.DataContext = new ItemViewModel();<br />
        }<br />
ItemViewModel.cs</p>
<p>namespace ScrollableContent.ViewModels<br />
{<br />
    public class ItemViewModel<br />
    {<br />
        public ItemViewModel()<br />
        {<br />
       <br />
        }<br />
    }<br />
}</p>
<p>We need a collection say items in the view model which will be binded to the listbox. Now if you go t the Image class, you will notice that the source has type ImageSource.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/pic1.png"><img class="alignnone size-full wp-image-1274" title="pic1" src="http://shamrat231.files.wordpress.com/2011/01/pic1.png" alt="" width="383" height="171" /></a></p>
<p>In other words, the Items need to be like this. The below code would have work if we are only binding the image. We also have text to bind. So a model needs to be created having the properties to be binded to the listbox.</p>
<p>    public class ItemViewModel<br />
    {<br />
        public List&lt;ImageSource&gt; Items { get; set; }</p>
<p>        public ItemViewModel()<br />
        {<br />
            this.Items = new List&lt;ImageSource&gt;();<br />
        }<br />
    }</p>
<p>So the changed code is<br />
    public class ItemViewModel<br />
    {<br />
        public List&lt;ItemModel&gt; Items { get; set; }</p>
<p>        public ItemViewModel()<br />
        {<br />
            this.Items = new List&lt;ItemModel&gt;();<br />
        }<br />
    }</p>
<p>where the ItemModel is</p>
<p>    public class ItemModel<br />
    {<br />
        public ImageSource Source { get; set; }<br />
        public string Description { get; set; }<br />
    }</p>
<p>and to this property is to be binded to the listbox. So the data template need to be changed.</p>
<p>                    &lt;StackPanel Orientation=&#8221;Horizontal&#8221;&gt;<br />
                        &lt;Image Source=&#8221;{Binding Source}&#8221; Height=&#8221;100&#8243; /&gt;<br />
                        &lt;TextBlock Text=&#8221;{Binding Description}&#8221; /&gt;<br />
                    &lt;/StackPanel&gt;</p>
<p>Lets add a simple dummy data to check if our Model-View-ViewModel actually works.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/pic2.png"><img class="alignnone size-full wp-image-1275" title="pic2" src="http://shamrat231.files.wordpress.com/2011/01/pic2.png" alt="" width="340" height="211" /></a></p>
<p>        public ItemViewModel()<br />
        {<br />
            this.Items = new List&lt;ItemModel&gt;();<br />
            this.Items.Add(new ItemModel() {<br />
                Source = new BitmapImage(new Uri(&#8220;../Images/unknown.png&#8221;, UriKind.Relative)),<br />
                Description = &#8220;This is some text&#8221;,<br />
            });<br />
        }</p>
<p>Now we have that cleared lets add some more data before animation is tried on collection. Instead of adding data on constructor, add all the data in another method for more simplicity. One thing to note here is that the listbox size will increase if we increase the size of the collection. Now restrict the current list box to show only two contents at a time.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/pic3.png"><img class="alignnone size-full wp-image-1276" title="pic3" src="http://shamrat231.files.wordpress.com/2011/01/pic3.png" alt="" width="485" height="229" /></a></p>
<p>        &lt;Canvas&gt;<br />
            &lt;Canvas.Clip&gt;<br />
            &lt;RectangleGeometry RadiusX=&#8221;10&#8243; RadiusY=&#8221;10&#8243; Rect=&#8221;0,0,450,350&#8243; /&gt;<br />
            &lt;/Canvas.Clip&gt;<br />
            &lt;ListBox ItemsSource=&#8221;{Binding Items}&#8221; HorizontalAlignment=&#8221;Center&#8221; VerticalAlignment=&#8221;Center&#8221;&gt;<br />
                &lt;ListBox.ItemTemplate&gt;<br />
                    &lt;DataTemplate&gt;<br />
                        &lt;StackPanel Orientation=&#8221;Horizontal&#8221; Margin=&#8221;0,10,5,5&#8243; Width=&#8221;450&#8243; Height=&#8221;150&#8243;&gt;<br />
                            &lt;Image Source=&#8221;{Binding Source}&#8221; Width=&#8221;100&#8243; Margin=&#8221;10&#8243;/&gt;<br />
                            &lt;TextBlock Text=&#8221;{Binding Description}&#8221; VerticalAlignment=&#8221;Center&#8221; TextWrapping=&#8221;Wrap&#8221; Width=&#8221;300&#8243; Margin=&#8221;10&#8243;/&gt;<br />
                        &lt;/StackPanel&gt;<br />
                    &lt;/DataTemplate&gt;<br />
                &lt;/ListBox.ItemTemplate&gt;<br />
            &lt;/ListBox&gt;<br />
        &lt;/Canvas&gt;</p>
<p> Ok, now we want to animate and scroll the content of the listbox we are going to translate the Y property of the listBox. To do this i will write a storyboard and manipulate it using parameter as shown below.</p>
<p>        public static Storyboard VerticalAnimation(UIElement controlToAnimate, double positionToMove)<br />
        {<br />
            DoubleAnimation da = new DoubleAnimation();<br />
            da.Duration = new Duration(TimeSpan.FromSeconds(1));</p>
<p>            Storyboard sb = new Storyboard();<br />
            sb.Duration = new Duration(TimeSpan.FromSeconds(1));<br />
            sb.Children.Add(da);</p>
<p>            Storyboard.SetTarget(da, controlToAnimate);<br />
            Storyboard.SetTargetProperty(da, new PropertyPath(&#8220;(UIElement.RenderTransform).(TranslateTransform.Y)&#8221;));<br />
            da.To = positionToMove;<br />
            return sb;<br />
        }</p>
<p>Ok, so basically this storyboard will either slide upwards or downwards and we can send a parameter &#8220;position to move&#8221; on this storyboard. This makes all of it very simple. Add two events and invoke this story board to do the slide up/down effect as shown below&#8230;</p>
<p>        int move = 0;<br />
        int imgShown = 2;<br />
        private const int h = 350;</p>
<p>        public MainPage()<br />
        {<br />
            InitializeComponent();<br />
            this.Next.Click += new System.Windows.RoutedEventHandler(Next_Click);<br />
            this.Back.Click += new System.Windows.RoutedEventHandler(Back_Click);<br />
            this.DataContext = new ItemViewModel();<br />
        }</p>
<p>        void Back_Click(object sender, System.Windows.RoutedEventArgs e)<br />
        {<br />
            if (imgShown != 2)<br />
            {<br />
                imgShown -= 2;<br />
                move += h;<br />
                VerticalAnimation(this.Collection, move).Begin();<br />
            }<br />
        }</p>
<p>        void Next_Click(object sender, System.Windows.RoutedEventArgs e)<br />
        {<br />
            if (this.Collection.Items.Count &gt; imgShown)<br />
            {<br />
                imgShown += 2;<br />
                move -= h;<br />
                VerticalAnimation(this.Collection, move).Begin();<br />
            }<br />
        }</p>
<p>This complete the whole coding. Now lets clean the view and move all the parameter to the App.xaml/resource dictionary as you see fit. In this case. after cleaning the view looks like this.</p>
<p><a href="http://shamrat231.files.wordpress.com/2011/01/pic4.png"><img class="alignnone size-full wp-image-1277" title="pic4" src="http://shamrat231.files.wordpress.com/2011/01/pic4.png" alt="" width="584" height="236" /></a></p>
<p>Now you might be wondering what happened to data template.  It is now in the being applied as style. In other words, the data template can now be reused for other types of control beside listbox.</p>
<p>         &lt;DataTemplate x:Key=&#8221;ItemContentTemplate&#8221;&gt;<br />
            &lt;Grid&gt;<br />
                &lt;StackPanel Orientation=&#8221;Horizontal&#8221; Margin=&#8221;0,10,5,5&#8243; Width=&#8221;450&#8243; Height=&#8221;150&#8243;&gt;<br />
                    &lt;Image Source=&#8221;{Binding Source}&#8221; Style=&#8221;{StaticResource imgStyle}&#8221;/&gt;<br />
                    &lt;TextBlock Text=&#8221;{Binding Description}&#8221; Style=&#8221;{StaticResource textStyle}&#8221; /&gt;<br />
                &lt;/StackPanel&gt;<br />
                &lt;HyperlinkButton Content=&#8221;Read more&#8221; Style=&#8221;{StaticResource LinkStyle}&#8221; /&gt;<br />
            &lt;/Grid&gt;<br />
        &lt;/DataTemplate&gt;</p>
<p>As always, you can download the source code from here <a title="silverlight download link" href="http://www.megaupload.com/?d=31C1UFIF" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/photo-gallery/'>photo gallery</a>, <a href='http://silverlightips.net/tag/scrolling-animation/'>scrolling animation</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1272/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1272&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2011/01/01/animated-vertical-scrollable-content/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/pic0.png" medium="image">
			<media:title type="html">pic0</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/pic1.png" medium="image">
			<media:title type="html">pic1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/pic2.png" medium="image">
			<media:title type="html">pic2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/pic3.png" medium="image">
			<media:title type="html">pic3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2011/01/pic4.png" medium="image">
			<media:title type="html">pic4</media:title>
		</media:content>
	</item>
		<item>
		<title>92. Animated Note Control using Triggers in Silverlight</title>
		<link>http://silverlightips.net/2010/10/29/custom-note-control-triggers-silverlight/</link>
		<comments>http://silverlightips.net/2010/10/29/custom-note-control-triggers-silverlight/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 22:25:59 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[custom control]]></category>
		<category><![CDATA[note control]]></category>
		<category><![CDATA[silverlight triggers]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1245</guid>
		<description><![CDATA[In this entry, I am going to create a simple note control. Let’s look at the initial code I have written below. The idea is that the control should be very simple and easy to create. Create a class and name it say&#8230;SlideNoteControl and then refer this control to your Mainpage.xaml where controls: is the namespace [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1245&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1245" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F10%2F29%2Fcustom-note-control-triggers-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-k5%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F10%2F29%2Fcustom-note-control-triggers-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-note-pad.png"><img class="alignnone size-full wp-image-1246" title="silverlight-note-pad" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-note-pad.png" alt="" width="407" height="194" /></a></p>
<p>In this entry, I am going to create a simple note control. Let’s look at the initial code I have written below. The idea is that the control should be very simple and easy to create. Create a class and name it say&#8230;SlideNoteControl and then refer this control to your Mainpage.xaml where <strong>controls</strong>: is the namespace of the project.</p>
<p>You can see the<strong> live example</strong> here<span style="color:#993300;"> </span><a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t92/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p><span style="text-decoration:underline;">SlideNoteControl.cs</span></p>
<p>    public class SlideNoteControl : ContentControl<br />
    {<br />
        public SlideNoteControl()<br />
            : base()<br />
        {<br />
            this.DefaultStyleKey = typeof(SlideNoteControl);<br />
        }</p>
<p>        public static readonly DependencyProperty NoteProperty = DependencyProperty<br />
            .Register(&#8220;Note&#8221;, typeof(UIElement), typeof(SlideNoteControl), null);</p>
<p>        public UIElement Note<br />
        {<br />
            get { return (UIElement)this.GetValue(SlideNoteControl.NoteProperty); }<br />
            set { this.SetValue(SlideNoteControl.NoteProperty, value); }<br />
        }<br />
    }</p>
<p>and here is how you use it in .xaml</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-blog-control.png"><img class="alignnone size-full wp-image-1248" title="silverlight-blog-control" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-blog-control.png" alt="" width="319" height="89" /></a></p>
<p>So basically I created a dependency property to hold content for this note control. Now I will open blend and go to app.xaml to design this note control. Now think of what a note control needs…a border with a shadow and some text in it. So basically the controltemplate should define a simple note looks. Look at the .xaml below</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-day.png"><img class="alignnone size-full wp-image-1249" title="silverlight-tips-day" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-day.png" alt="" width="493" height="246" /></a></p>
<p><span style="text-decoration:underline;">App.xaml</span><br />
        &lt;!&#8211;SlideNoteControl&#8211;&gt;<br />
        &lt;Style TargetType=&#8221;controls:SlideNoteControl&#8221;&gt;<br />
            &lt;Setter Property=&#8221;Foreground&#8221; Value=&#8221;#FF000000&#8243;/&gt;<br />
            &lt;Setter Property=&#8221;HorizontalContentAlignment&#8221; Value=&#8221;Left&#8221;/&gt;<br />
            &lt;Setter Property=&#8221;VerticalContentAlignment&#8221; Value=&#8221;Top&#8221;/&gt;<br />
            &lt;Setter Property=&#8221;Template&#8221;&gt;<br />
                &lt;Setter.Value&gt;<br />
                    &lt;ControlTemplate TargetType=&#8221;controls:SlideNoteControl&#8221;&gt;<br />
                        &lt;Grid&gt;<br />
                            &lt;Grid.RowDefinitions&gt;<br />
                                &lt;RowDefinition Height=&#8221;Auto&#8221;/&gt;<br />
                            &lt;/Grid.RowDefinitions&gt;<br />
                            &lt;Border BorderThickness=&#8221;1&#8243; BorderBrush=&#8221;Black&#8221; Width=&#8221;{TemplateBinding Width}&#8221; Height=&#8221;{TemplateBinding Height}&#8221; Background=&#8221;{TemplateBinding Background}&#8221; Grid.Row=&#8221;0&#8243;&gt;<br />
                                &lt;Border.Effect&gt;<br />
                                    &lt;DropShadowEffect Color=&#8221;#FFE7E2E2&#8243; BlurRadius=&#8221;10&#8243; /&gt;<br />
                                &lt;/Border.Effect&gt;<br />
                                &lt;ContentPresenter Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding Note}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221; Margin=&#8221;10&#8243;/&gt;<br />
                            &lt;/Border&gt;<br />
                        &lt;/Grid&gt;<br />
                    &lt;/ControlTemplate&gt;<br />
                &lt;/Setter.Value&gt;<br />
            &lt;/Setter&gt;<br />
        &lt;/Style&gt;<br />
    &lt;/Application.Resources&gt;</p>
<p>and the output looks like this&#8230;the below image shows a readonly mode note. I say that this is readonly as i have used textblock only.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-triggers.png"><img class="alignnone size-full wp-image-1251" title="silverlight-triggers" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-triggers.png" alt="" width="489" height="215" /></a></p>
<p>However, you can chang the textblock to any control that you feel like. For eg, if you want to write on the note&#8230;.great use a TextBox.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>        <span style="text-decoration:underline;">&lt;!&#8211;Read Only Note Control&#8211;&gt;</span><br />
        &lt;controls:SlideNoteControl Height=&#8221;170&#8243; Background=&#8221;#faeb76&#8243; Margin=&#8221;0,0,10,10&#8243; VerticalAlignment=&#8221;Bottom&#8221;&gt;<br />
            &lt;controls:SlideNoteControl.Note&gt;<br />
                &lt;TextBlock&gt;&lt;Run Text=&#8221;Animated Note Sample Demo&#8221; FontWeight=&#8221;Black&#8221;/&gt;&lt;Run Text=&#8221; &#8220;/&gt;&lt;LineBreak/&gt;&lt;LineBreak/&gt;&lt;Run Text=&#8221; &#8220;/&gt;&lt;Italic&gt;&lt;Run Text=&#8221;This note is customizable, flexible to display silverlight notes&#8221;/&gt;&lt;/Italic&gt;&lt;Run Text=&#8221; &#8220;/&gt;&lt;LineBreak/&gt;&lt;Run Text=&#8221; &#8220;/&gt;&lt;LineBreak/&gt;&lt;Run Text=&#8221; &#8220;/&gt;&lt;Run Text=&#8221;Click on the close button to hide this notification.&#8221; /&gt;&lt;/TextBlock&gt;<br />
            &lt;/controls:SlideNoteControl.Note&gt;<br />
        &lt;/controls:SlideNoteControl&gt;</p>
<p>       <br />
        <span style="text-decoration:underline;">&lt;!&#8211;TextBox Note Control&#8211;&gt;</span><br />
        &lt;controls:SlideNoteControl x:Name=&#8221;TextNoteControl&#8221; Height=&#8221;100&#8243; Background=&#8221;#faeb76&#8243; Margin=&#8221;0,10,10,10&#8243; VerticalAlignment=&#8221;Top&#8221;&gt;<br />
            &lt;controls:SlideNoteControl.Note&gt;<br />
                &lt;TextBox Text=&#8221;This is editable text box. Something important?, start typing here&#8230;&#8221; Background=&#8221;Transparent&#8221; TextWrapping=&#8221;Wrap&#8221; BorderThickness=&#8221;0&#8243; Width=&#8221;{Binding TextNoteControl, ElementName=Width}&#8221; /&gt;<br />
            &lt;/controls:SlideNoteControl.Note&gt;<br />
        &lt;/controls:SlideNoteControl&gt;</p>
<p>Now the note should slide and when click close. Let’s use trigger to create a storyboard and stop it when close icon clicked. For demonstration purpose, the above example uses a textblock. First of all create a simple <em>storyboard which translate the note control from left to right in blend</em>. How to do that?&#8230;ok just hold the slide control and create two keyframe which will translate this control. Obviously the storyboard should be in the styles. For now lets look at the code below.</p>
<p><span style="text-decoration:underline;">Dummy StoryBoard Created in Blend</span></p>
<p>  &lt;Storyboard x:Name=&#8221;Storyboard1&#8243;&gt;<br />
   &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=&#8221;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&#8221; Storyboard.TargetName=&#8221;slideNoteControl&#8221;&gt;<br />
    &lt;EasingDoubleKeyFrame KeyTime=&#8221;0&#8243; Value=&#8221;380&#8243;/&gt;<br />
    &lt;EasingDoubleKeyFrame KeyTime=&#8221;0:0:0.5&#8243; Value=&#8221;0&#8243;/&gt;<br />
   DoubleAnimationUsingKeyFrames&gt;<br />
  &lt;/Storyboard&gt;</p>
<p>I need to animate my note control. As a result, the targetName need to change when this storyboard will be put inside the style as shown below.</p>
<p><span style="text-decoration:underline;">App.xaml</span><br />
                            &lt;Grid.Triggers&gt;<br />
                                &lt;EventTrigger RoutedEvent=&#8221;Grid.Loaded&#8221;&gt;<br />
                                    &lt;BeginStoryboard&gt;<br />
                                        &lt;Storyboard Storyboard.TargetName=&#8221;NoteControlBorder&#8221; Storyboard.TargetProperty=&#8221;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&#8221; &gt;<br />
                                            &lt;DoubleAnimationUsingKeyFrames&gt;<br />
                                                &lt;EasingDoubleKeyFrame KeyTime=&#8221;0&#8243; Value=&#8221;760&#8243;/&gt;<br />
                                                &lt;EasingDoubleKeyFrame KeyTime=&#8221;0:0:01&#8243; Value=&#8221;0&#8243;/&gt;<br />
                                            &lt;/DoubleAnimationUsingKeyFrames&gt;<br />
                                        &lt;/Storyboard&gt;<br />
                                    &lt;/BeginStoryboard&gt;<br />
                                EventTrigger&gt;<br />
                            &lt;/Grid.Triggers&gt;</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-triggers-custom.png"><img class="alignnone size-full wp-image-1252" title="silverlight-triggers-custom" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-triggers-custom.png" alt="" width="458" height="214" /></a></p>
<p>Great, now the sliding animation is working. One last touch that is needed is that the current note control needs  a close button. For this i will be using triggers from blend. The below code shows how I manipulate the storyboard using triggers when the close button is clicked.</p>
<p>                                    &lt;Border CornerRadius=&#8221;2&#8243; Background=&#8221;Red&#8221; Width=&#8221;16&#8243; Height=&#8221;16&#8243; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Left&#8221; Margin=&#8221;-5,-5,0,0&#8243; &gt;<br />
                                        &lt;HyperlinkButton Foreground=&#8221;White&#8221; Content=&#8221;X&#8221;  IsTabStop=&#8221;False&#8221; HorizontalContentAlignment=&#8221;Center&#8221;&gt;<br />
                                            &lt;i:Interaction.Triggers&gt;<br />
                                                &lt;i:EventTrigger EventName=&#8221;Click&#8221;&gt;<br />
                                                    &lt;ei:ControlStoryboardAction&gt;<br />
                                                        &lt;ei:ControlStoryboardAction.Storyboard&gt;<br />
                                                            &lt;Storyboard &gt;<br />
                                                                &lt;DoubleAnimationUsingKeyFrames Storyboard.TargetName=&#8221;NoteControlBorder&#8221; Storyboard.TargetProperty=&#8221;(UIElement.RenderTransform).(CompositeTransform.TranslateX)&#8221;&gt;<br />
                                                                    &lt;EasingDoubleKeyFrame KeyTime=&#8221;0&#8243; Value=&#8221;0&#8243;/&gt;<br />
                                                                    &lt;EasingDoubleKeyFrame KeyTime=&#8221;0:0:01&#8243; Value=&#8221;760&#8243;/&gt;<br />
                                                                &lt;/DoubleAnimationUsingKeyFrames&gt;<br />
                                                            &lt;/Storyboard&gt;<br />
                                                        ei:ControlStoryboardAction.Storyboard&gt;<br />
                                                    ei:ControlStoryboardAction&gt;<br />
                                                &lt;/i:EventTrigger&gt;<br />
                                            &lt;/i:Interaction.Triggers&gt;<br />
                                        &lt;/HyperlinkButton&gt;<br />
                                    &lt;/Border&gt;</p>
<p>Here is the output..</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-samples.png"><img class="alignnone size-full wp-image-1255" title="silverlight-samples" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-samples.png" alt="" width="398" height="124" /></a></p>
<p>As always, you can download the source code from here <a href="http://www.megaupload.com/?d=ENV5FC1I" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/custom-control/'>custom control</a>, <a href='http://silverlightips.net/tag/note-control/'>note control</a>, <a href='http://silverlightips.net/tag/silverlight-triggers/'>silverlight triggers</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1245&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/10/29/custom-note-control-triggers-silverlight/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-note-pad.png" medium="image">
			<media:title type="html">silverlight-note-pad</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-blog-control.png" medium="image">
			<media:title type="html">silverlight-blog-control</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-day.png" medium="image">
			<media:title type="html">silverlight-tips-day</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-triggers.png" medium="image">
			<media:title type="html">silverlight-triggers</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-triggers-custom.png" medium="image">
			<media:title type="html">silverlight-triggers-custom</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-samples.png" medium="image">
			<media:title type="html">silverlight-samples</media:title>
		</media:content>
	</item>
		<item>
		<title>91. Custom preloader in Silverlight</title>
		<link>http://silverlightips.net/2010/10/03/custom-preloader-silverlight/</link>
		<comments>http://silverlightips.net/2010/10/03/custom-preloader-silverlight/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 23:21:04 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[preloader silverlight]]></category>
		<category><![CDATA[silverlight preloader]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1216</guid>
		<description><![CDATA[Lets start this entry by first congratulating newly awarded (and re-awarded) Silverlight MVPs.  Congratulation to all of them&#8230;!!! Ok, now back to today&#8217;s entry. You can see the live example here [live demo] (Put on your headphone : ) The SOURCE CODE(.zip) is at the end of the page for download. The first thing about creating a preloader is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1216&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1216" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F10%2F03%2Fcustom-preloader-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-jC%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F10%2F03%2Fcustom-preloader-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-blogs.png"><img class="alignnone size-full wp-image-1217" title="silverlight-blogs" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-blogs.png" alt="" width="407" height="192" /></a></p>
<p>Lets start this entry by first congratulating newly awarded (and re-awarded) <a href="http://johnpapa.net/silverlight/8-new-silverlight-mvps/" target="_blank"><span style="color:#993300;">Silverlight MVPs</span></a>.  Congratulation to all of them&#8230;!!!</p>
<p>Ok, now back to today&#8217;s entry. You can see the<strong> live example</strong> here<span style="color:#993300;"> </span><a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t91/default.html" target="_blank"><span style="color:#993300;">[live demo]</span></a> (<em>Put on your headphone </em>: )</p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>The <span style="text-decoration:underline;">first thing</span> about creating a preloader is that you should be using a separate xaml file which can be pointed from Silverlight  object tag. For now, look at the code below,</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-1.png"><img class="alignnone size-full wp-image-1218" title="silverlight-tips-preloader-1" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-1.png" alt="" width="628" height="80" /></a></p>
<p>Right click on you .web and add a Silverlight 1.0 Jscript Page. A sample xaml page with Canvas should get created along with a js file.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-2.png"><img class="alignnone size-full wp-image-1219" title="silverlight-tips-preloader-2" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-2.png" alt="" width="174" height="144" /></a></p>
<p>With the help of js function, we can actually manipulate the xaml file. Before I get to that, lets open blend and design a sample preloader.  The idea is very simple. There will be a text, where it will show the downloaded progress and&#8230;a bar which will show the progress.  It is more flexible if you do the design in MainPage.xaml and then relocate the code in your customPreloader.xaml. I have taken the design idea of the bar from <a href="http://blog.theflashblog.com/?p=916" target="_blank">here</a></p>
<p><span style="text-decoration:underline;">CustomPreloader.xaml</span></p>
<p>&lt;Grid Background=”#444444″ xmlns=”<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>” xmlns:x=”<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>“&gt;<br />
  &lt;Border Background=&#8221;#272727&#8243; Width=&#8221;300&#8243; CornerRadius=&#8221;5&#8243; Height=&#8221;77&#8243;&gt;<br />
    &lt;Canvas Margin=&#8221;10&#8243;&gt;<br />
      &lt;TextBlock Text=&#8221;SILVERLIGHTIPS.NET&#8221; Foreground=&#8221;#cbcbcb&#8221; Height=&#8221;15&#8243;/&gt;<br />
      &lt;Border BorderBrush=&#8221;#1b1814&#8243; Margin=&#8221;238,0,0,0&#8243; Height=&#8221;15&#8243; Width=&#8221;40&#8243;&gt;<br />
        &lt;TextBlock x:Name=&#8221;bartext&#8221; Text=&#8221;0%&#8221; Foreground=&#8221;#cbcbcb&#8221; HorizontalAlignment=&#8221;Right&#8221;/&gt;<br />
      &lt;/Border&gt;<br />
      &lt;Border BorderBrush=&#8221;#1b1814&#8243; BorderThickness=&#8221;1&#8243; Background=&#8221;#434544&#8243; Width=&#8221;280&#8243; Height=&#8221;30&#8243; Margin=&#8221;0,20&#8243; CornerRadius=&#8221;2&#8243;&gt;<br />
        &lt;Border x:Name=&#8221;bar&#8221; Width=&#8221;0&#8243;  HorizontalAlignment=&#8221;Left&#8221;&gt;<br />
          &lt;Border.Background&gt;<br />
            &lt;LinearGradientBrush EndPoint=&#8221;0.5,1&#8243; StartPoint=&#8221;0.5,0&#8243;&gt;<br />
              &lt;GradientStop Color=&#8221;#FF1FA0FB&#8221; Offset=&#8221;0&#8243;/&gt;<br />
              &lt;GradientStop Color=&#8221;#FF168CDB&#8221; Offset=&#8221;1&#8243;/&gt;<br />
              &lt;GradientStop Color=&#8221;#FF1295ED&#8221; Offset=&#8221;0.465&#8243;/&gt;<br />
              &lt;GradientStop Color=&#8221;#FF0F89DC&#8221; Offset=&#8221;0.865&#8243;/&gt;<br />
              &lt;GradientStop Color=&#8221;#FF0D9BFA&#8221; Offset=&#8221;0.165&#8243;/&gt;<br />
            &lt;/LinearGradientBrush&gt;<br />
          &lt;/Border.Background&gt;<br />
        &lt;/Border&gt;<br />
      &lt;/Border&gt;<br />
    &lt;/Canvas&gt;<br />
  &lt;/Border&gt;<br />
&lt;/Grid&gt;</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-3.png"><img class="alignnone size-full wp-image-1220" title="silverlight-tips-preloader-3" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-3.png" alt="" width="443" height="341" /></a> </p>
<p>Now lets add some bulky data. For demonstration purpose, I will add a random mp3 file.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>   &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;#444444&#8243;&gt;</p>
<p>        &lt;MediaElement Source=&#8221;The_Breaking_Of_The_Fellowship.mp3&#8243; AutoPlay=&#8221;True&#8221; /&gt;</p>
<p>    &lt;/Grid&gt;</p>
<p>Compile the project. Your .xap file size should increase. My speed is not that great …so this size is good enough for test purpose.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-4.png"><img class="alignnone size-full wp-image-1222" title="silverlight-tips-preloader-4" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-4.png" alt="" width="624" height="317" /></a><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-51.png"><img class="alignnone size-full wp-image-1242" title="silverlight-tips-preloader-5" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-51.png" alt="" width="309" height="140" /></a><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-5.png"></a></p>
<p>Now lets get back to the js file. We want to write a function where we can manipulate the width of the bar and text in xaml. This can be done by writing the function assigned in the silverlight object tag as shown below.</p>
<p><span style="text-decoration:underline;">customPreloader.js</span></p>
<p>function SourceDownloadProgressChanged(s, e) {<br />
    var bartext = s.findname(&#8220;bartext&#8221;);<br />
    var bar = s.findname(&#8220;bar&#8221;);<br />
    if (bartext != null || bar != null) {<br />
        var value = Math.round(e.progress * 100)<br />
        bartext.Text = value + &#8220;%&#8221;;<br />
        var newWidth = 2.8 * value;<br />
        bar.Width = Math.round(newWidth)<br />
    }<br />
}</p>
<p>Notice that the xaml “bar” parent has border width 280. So if we divided the width in 100 region each part will be 2.8. So in js our bar.Width is being calculated as bar.Width = Math.round(2.8 * value) where values is the current percentage downloaded. The important thing to remember is to point the reference of the js file in your page.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-6.png"><img class="alignnone size-full wp-image-1223" title="silverlight-tips-preloader-6" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-6.png" alt="" width="495" height="63" /></a></p>
<p>Finally when it is published, make sure to add the xaml file.<a href="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-7.png"><img class="alignnone size-full wp-image-1225" title="silverlight-tips-preloader-7" src="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-7.png" alt="" width="204" height="125" /></a></p>
<p>As always, you can download the source code from here <a href="http://www.megaupload.com/?d=UBJCUYBC" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/preloader-silverlight/'>preloader silverlight</a>, <a href='http://silverlightips.net/tag/silverlight-preloader/'>silverlight preloader</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1216&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/10/03/custom-preloader-silverlight/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-blogs.png" medium="image">
			<media:title type="html">silverlight-blogs</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-1.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-2.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-3.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-4.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-51.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-5</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-6.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-6</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/10/silverlight-tips-preloader-7.png" medium="image">
			<media:title type="html">silverlight-tips-preloader-7</media:title>
		</media:content>
	</item>
		<item>
		<title>90. Drawing on Image in Silverlight</title>
		<link>http://silverlightips.net/2010/09/25/drawing-image-inkpresenter-silverlight/</link>
		<comments>http://silverlightips.net/2010/09/25/drawing-image-inkpresenter-silverlight/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 06:26:32 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[ink Presenter]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1201</guid>
		<description><![CDATA[In last entry, I talked about drag-and-drop image. In this I will write about how you can draw on your image and maybe in next post save it. Today for drawing, I will use InkPresenter. You can see the live example here [live demo]    The SOURCE CODE(.zip) is at the end of the page for download. Lets [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1201&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1201" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F25%2Fdrawing-image-inkpresenter-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-jn%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F25%2Fdrawing-image-inkpresenter-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/09/t90-silverlight-tips1.png"><img class="alignnone size-full wp-image-1212" title="t90-silverlight-tips" src="http://shamrat231.files.wordpress.com/2010/09/t90-silverlight-tips1.png" alt="" width="579" height="312" /></a><a href="http://shamrat231.files.wordpress.com/2010/09/t90-silverlight-tips.png"></a></p>
<p>In last entry, I talked about <a href="http://silverlightips.net/2010/09/16/file-drag-drop-in-silverlight/" target="_blank">drag-and-drop image</a>. In this I will write about how you can <span style="text-decoration:underline;">draw</span> on your image and maybe in next post <span style="text-decoration:underline;">save it</span>. Today for drawing, I will use InkPresenter.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t90/" target="_blank"><span style="color:#993300;">[live demo]</span></a>   </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>Lets look at initial coding.</p>
<p>    &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
        &lt;InkPresenter x:Name=&#8221;ink&#8221; MouseLeftButtonDown=&#8221;ink_MouseLeftButtonDown&#8221; MouseMove=&#8221;ink_MouseMove&#8221; MouseLeftButtonUp=&#8221;ink_MouseLeftButtonUp&#8221;  /&gt;<br />
        &lt;Canvas Width=&#8221;800&#8243; Height=&#8221;545&#8243;&gt;<br />
        &lt;Image Source=&#8221;Images/Rain_Dance_03_by_fbuk.jpg&#8221; /&gt;<br />
        &lt;/Canvas&gt;<br />
    &lt;/Grid&gt;</p>
<p>As you can see in the above code, I have added 3 event handlers. Lets talk about the first one.</p>
<p>        private void ink_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)<br />
        {<br />
 // while pressed, we want to start drawing<br />
        }</p>
<p>So here goes the code.</p>
<p>        private void ink_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)<br />
        {<br />
            //capturing the ink<br />
            ink.CaptureMouse();<br />
            //current set of point collection<br />
            StylusPointCollection points = e.StylusDevice.GetStylusPoints(ink);<br />
            currentStroke = new Stroke(points);<br />
            //set color of stroke<br />
            currentStroke.DrawingAttributes.OutlineColor = Colors.White;<br />
            currentStroke.DrawingAttributes.Color = Colors.White;<br />
            //adding current stroke<br />
            ink.Strokes.Add(currentStroke);<br />
        }</p>
<p>Now comes the mouse move region. In here we are adding the points to our current stroke.</p>
<p>        private void ink_MouseMove(object sender, MouseEventArgs e)<br />
        {<br />
            if (currentStroke != null)<br />
            {<br />
                StylusPointCollection points = e.StylusDevice.GetStylusPoints(ink);<br />
                currentStroke.StylusPoints.Add(points);<br />
            }<br />
        }</p>
<p>and the last part where we release and reset everything….</p>
<p>        private void ink_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)<br />
        {<br />
            //releasing the inkPrensenter<br />
            ink.ReleaseMouseCapture();<br />
            //setting to null so when mouse moved when not pressed&#8230;no draw.<br />
            currentStroke = null;<br />
        }</p>
<p>Now, lets run the app. Try drawing, nothing happens. So basically we have made an obvious mistake.  If you look at the xaml coding, we have set the ink presenter behind the image. So no wonder, nothing gets drawn. Lets fix it.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>    &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
        &lt;Canvas Width=&#8221;800&#8243; Height=&#8221;545&#8243;&gt;<br />
        &lt;Image Source=&#8221;Images/Rain_Dance_03_by_fbuk.jpg&#8221; /&gt;<br />
        &lt;/Canvas&gt;<br />
        &lt;InkPresenter x:Name=&#8221;ink&#8221; Background=&#8221;Transparent&#8221; MouseLeftButtonDown=&#8221;ink_MouseLeftButtonDown&#8221; MouseMove=&#8221;ink_MouseMove&#8221; MouseLeftButtonUp=&#8221;ink_MouseLeftButtonUp&#8221;  Cursor=&#8221;Arrow&#8221; /&gt;<br />
        &lt;HyperlinkButton Content=&#8221;Developed by Sharker Khaleed Mahmud. Available at <a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; IsTabStop=&#8221;False&#8221; Height=&#8221;30&#8243; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Center&#8221; Foreground=&#8221;White&#8221;  /&gt;<br />
        &lt;TextBlock Text=&#8221;Press your mouse and start drawing&#8230;&#8221; VerticalAlignment=&#8221;Bottom&#8221; HorizontalAlignment=&#8221;Right&#8221; FontSize=&#8221;24&#8243; Foreground=&#8221;White&#8221; /&gt;<br />
    &lt;/Grid&gt;</p>
<p>Run the app. It should work. Now let&#8217;s try drawing on the image. I took the image from deviant art gallery for demonstration purpose.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-blog.png"><img class="alignnone size-full wp-image-1204" title="silverlight-blog" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-blog.png" alt="" width="366" height="239" /></a></p>
<p>In this way, we can customize any image and give the feeling of personal touch. In next entry, I will talk more about saving this image.</p>
<p>As always, you can download the source code from here<span style="color:#993300;"> </span><a href="http://www.megaupload.com/?d=Y9A1MAWW" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/ink-presenter/'>ink Presenter</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1201/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1201/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1201&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/09/25/drawing-image-inkpresenter-silverlight/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/t90-silverlight-tips1.png" medium="image">
			<media:title type="html">t90-silverlight-tips</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-blog.png" medium="image">
			<media:title type="html">silverlight-blog</media:title>
		</media:content>
	</item>
		<item>
		<title>89. File Drag-and-Drop Support in Silverlight</title>
		<link>http://silverlightips.net/2010/09/16/file-drag-drop-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/09/16/file-drag-drop-in-silverlight/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 10:22:43 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[file drag drop silverlight]]></category>
		<category><![CDATA[file drag silverlight]]></category>
		<category><![CDATA[file drop silverlight]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1183</guid>
		<description><![CDATA[In this entry, I will talk about drop support that came with Silverlight 4. It is actually very simple to use and you can take the advantage of it if you happen to create a simple Silverlight Image Editor. This is a simple introduction to an editor currently I am working to customize images and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1183&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1183" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F16%2Ffile-drag-drop-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-j5%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F16%2Ffile-drag-drop-in-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-11.png"><img class="alignnone size-full wp-image-1194" title="silverlight-tips-89-1" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-11.png" alt="" width="851" height="361" /></a><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-1.png"></a></p>
<p>In this entry, I will talk about drop support that came with Silverlight 4. It is actually very simple to use and you can take the advantage of it if you happen to create a simple<em> <span style="text-decoration:underline;">Silverlight Image Editor</span></em>. This is a simple introduction to an editor currently I am working to customize images and in future apply adobe effects. However, in this entry, I will talk about only image(s) drag and drop from <span style="text-decoration:underline;">external place</span> to your Silverlight application.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t89/" target="_blank"><span style="color:#993300;">[live demo]</span></a><span style="color:#993300;"> </span>  </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>First I will start coding drag feature. An image at the moment can easily be dragged using the default MouseDragElementBehavior. So just add that to your image and it will become draggable as shown in the code below.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>    &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
        &lt;Image x:Name=&#8221;DropImage&#8221; Width=&#8221;400&#8243; Cursor=&#8221;Hand&#8221;&gt;<br />
            &lt;i:Interaction.Behaviors&gt;<br />
                &lt;ei:MouseDragElementBehavior ConstrainToParentBounds=&#8221;True&#8221;/&gt;<br />
            &lt;/i:Interaction.Behaviors&gt;<br />
        &lt;/Image&gt;<br />
    &lt;/Grid&gt;</p>
<p>Silverlight is too fun, when coding gets this simple <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . So the image can now be dragged around. Now lets add the drop feature.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-2.png"><img class="alignnone size-full wp-image-1186" title="silverlight-tips-89-2" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-2.png" alt="" width="627" height="76" /></a></p>
<p>For making everything very simple, I will just now add AllowDrop=”True” and then add a drop handler to handle any file that is being dropped.</p>
<p>Now, lets move to the code behind. For demonstration purpose, I will use images from deviantArt gallery.</p>
<p><span style="text-decoration:underline;">MainPage.xaml.cs</span></p>
<p>        //make sure you drag an image to drop<br />
        private void LayoutRoot_Drop(object sender, DragEventArgs e)<br />
        {<br />
            if (e.Data != null)<br />
            {</p>
<p>            }<br />
        }</p>
<p>Now reading a drop file, this can be easily be done as shown below. You can drop multiple files in the editor, but in this scenario I will code to get <em>only one file</em>.</p>
<p>                //reading the drop file<br />
                FileInfo file = ((FileInfo[])e.Data.GetData(DataFormats.FileDrop)).FirstOrDefault();</p>
<p>Now, we have actually got hold of the file that is being dropped. At the moment, I have assumed that the file drop is an image. If it is not then you should implement code to handle that kind of scenario. I will not talk about that but go ahead and assuming the user did drop an image file.</p>
<p>So we now have a reference to the dropped file. Lets create BitmapImage of the dropped file.</p>
<p>                //creating a bitmapImage<br />
                BitmapImage img = new BitmapImage();<br />
               <br />
                using (Stream s = file.OpenRead())<br />
                {<br />
                    img.SetSource(s);<br />
                }</p>
<p>Once that is done, set the image to your image control in xaml like this.</p>
<p>                //setting the image in xaml<br />
                DropImage.Source = img;</p>
<p>You are done applying the above image. Now lets save the collection of drop image.</p>
<p>        &lt;StackPanel x:Name=&#8221;DropCollection&#8221; Height=&#8221;100&#8243; Margin=&#8221;10,30,10,10&#8243; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Center&#8221; Orientation=&#8221;Horizontal&#8221;&gt;<br />
        &lt;/StackPanel&gt;</p>
<p>Everytime a image is dropped, I will add it to my Stackpanel. You can add scrollviewer or use ItemsControl to hold the collection. I will be using stackpanel for demonstration purpose.</p>
<p>        //make sure you drag an image to drop<br />
        private void LayoutRoot_Drop(object sender, DragEventArgs e)<br />
        {<br />
            if (e.Data != null)<br />
            {<br />
                //reading the drop file<br />
                FileInfo file = ((FileInfo[])e.Data.GetData(DataFormats.FileDrop)).FirstOrDefault();</p>
<p>                //creating a bitmapImage<br />
                BitmapImage img = new BitmapImage();<br />
               <br />
                using (Stream s = file.OpenRead())<br />
                {<br />
                    img.SetSource(s);<br />
                }</p>
<p>                //setting the image in xaml<br />
                DropImage.Source = img;</p>
<p>                Image newImage = new Image { Source = img };<br />
                newImage.MouseLeftButtonDown += (a, b) =&gt;<br />
                {<br />
                    DropImage.Source = newImage.Source;<br />
                };</p>
<p>                DropCollection.Children.Add(newImage);<br />
            }<br />
        }</p>
<p>As you can see, that dropped image is added to the collection. Click on the collection image and that will be displayed on the center image. This sample can easily be updated allowing multiple Images to be dragged and dropped but I will continue with it on my next entry.</p>
<p>As always, you can download the source code from here <a href="http://www.megaupload.com/?d=4G4468ZV" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/file-drag-drop-silverlight/'>file drag drop silverlight</a>, <a href='http://silverlightips.net/tag/file-drag-silverlight/'>file drag silverlight</a>, <a href='http://silverlightips.net/tag/file-drop-silverlight/'>file drop silverlight</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1183&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/09/16/file-drag-drop-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-11.png" medium="image">
			<media:title type="html">silverlight-tips-89-1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-89-2.png" medium="image">
			<media:title type="html">silverlight-tips-89-2</media:title>
		</media:content>
	</item>
		<item>
		<title>88. Clipboard Support in Silverlight</title>
		<link>http://silverlightips.net/2010/09/15/clipboard-copy-paste-silverlight/</link>
		<comments>http://silverlightips.net/2010/09/15/clipboard-copy-paste-silverlight/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 06:17:43 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[clipboard silverlight]]></category>
		<category><![CDATA[copy paste silverlight]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1172</guid>
		<description><![CDATA[In this entry I am going to do a simple scenario involving copy and paste. Basically, the clipboard class has three members, ContainsText, GetText and SetText. To demonstrate, I will use a simple textbox. You can see the live example here [live demo]    The SOURCE CODE(.zip) is at the end of the page for download. Create a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1172&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1172" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F15%2Fclipboard-copy-paste-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-iU%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F15%2Fclipboard-copy-paste-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-1.png"><img class="alignnone size-full wp-image-1173" title="silverlight-tips-88-1" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-1.png" alt="" width="406" height="349" /></a></p>
<p>In this entry I am going to do a simple scenario involving copy and paste. Basically, the clipboard class has three members, ContainsText, GetText and SetText. To demonstrate, I will use a simple textbox.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-2.png"><img class="alignnone size-full wp-image-1174" title="silverlight-tips-88-2" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-2.png" alt="" width="216" height="116" /></a></p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t88/" target="_blank"><span style="color:#993300;">[live demo]</span></a>   </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>Create a simple xaml having a buttons and a textbox. Add a handler to each button so we can write code against the click events.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>    &lt;toolkit:ExpressionDarkTheme&gt;<br />
    &lt;StackPanel x:Name=&#8221;LayoutRoot&#8221;&gt;<br />
        &lt;TextBox Text=&#8221;Copy paste sample&#8221; TextWrapping=&#8221;Wrap&#8221; Width=&#8221;400&#8243; Height=&#8221;300&#8243; /&gt;<br />
        &lt;StackPanel Orientation=&#8221;Horizontal&#8221; HorizontalAlignment=&#8221;Center&#8221;&gt;<br />
            &lt;Button Width=&#8221;120&#8243; Height=&#8221;30&#8243; Content=&#8221;Copy&#8221; Margin=&#8221;5&#8243; Click=&#8221;Button_Click&#8221; /&gt;<br />
            &lt;Button Width=&#8221;120&#8243; Height=&#8221;30&#8243; Content=&#8221;Paste&#8221; Margin=&#8221;5&#8243; Click=&#8221;Button_Click&#8221;/&gt;<br />
        &lt;/StackPanel&gt;<br />
    &lt;/StackPanel&gt;<br />
    &lt;/toolkit:ExpressionDarkTheme&gt;</p>
<p><span style="text-decoration:underline;">MainPage.xaml.cs</span></p>
<p>        private void Button_Click(object sender, RoutedEventArgs e)<br />
        {<br />
            switch (((Button)sender).Content.ToString())<br />
            {<br />
                case &#8220;Copy&#8221;:<br />
                    {<br />
                        // code goes here<br />
                        break;<br />
                    }<br />
                case &#8220;Paste&#8221;:<br />
                    {<br />
                        // code goes here<br />
                        break;<br />
                    }<br />
            }<br />
        }</p>
<p>In the above code, I created a basic skeleton of the interface and sample code related to the button click event. Now lets take a paste scenario. Open a site and copy some text as shown in the below example.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-3.png"><img class="alignnone size-full wp-image-1175" title="silverlight-tips-88-3" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-3.png" alt="" width="607" height="177" /></a></p>
<p>Now, we want this text to be pasted in Silverlight so using clipboard support we can code like this</p>
<p>                case &#8220;Paste&#8221;:<br />
                    {<br />
                        if (Clipboard.ContainsText())<br />
                        {<br />
                            tbText.Text = Clipboard.GetText();<br />
                        }<br />
                        break;<br />
                    }</p>
<p>Now run the app and click paste button.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-4.png"><img class="alignnone size-full wp-image-1176" title="silverlight-tips-88-4" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-4.png" alt="" width="689" height="368" /></a></p>
<p>Now lets handle the copy part.</p>
<p>                case &#8220;Copy&#8221;:<br />
                    {<br />
                        Clipboard.SetText(tbText.SelectedText);<br />
                        break;<br />
                    }</p>
<p>Now I will select part of the pasted text and copy</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-5.png"><img class="alignnone size-full wp-image-1177" title="silverlight-tips-88-5" src="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-5.png" alt="" width="388" height="338" /></a></p>
<p>As always, you can download the source code from here <a href="http://www.megaupload.com/?d=1U9CRXWD" target="_blank"><span style="color:#993300;">[download link]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/clipboard-silverlight/'>clipboard silverlight</a>, <a href='http://silverlightips.net/tag/copy-paste-silverlight/'>copy paste silverlight</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1172&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/09/15/clipboard-copy-paste-silverlight/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-1.png" medium="image">
			<media:title type="html">silverlight-tips-88-1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-2.png" medium="image">
			<media:title type="html">silverlight-tips-88-2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-3.png" medium="image">
			<media:title type="html">silverlight-tips-88-3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-4.png" medium="image">
			<media:title type="html">silverlight-tips-88-4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/silverlight-tips-88-5.png" medium="image">
			<media:title type="html">silverlight-tips-88-5</media:title>
		</media:content>
	</item>
		<item>
		<title>87. Adding DropTargetValidation to MouseDragElementBehavior in Silverlight</title>
		<link>http://silverlightips.net/2010/09/04/mousedragelementbehavior-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/09/04/mousedragelementbehavior-in-silverlight/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 06:44:01 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[MouseDragElementBehavior]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1146</guid>
		<description><![CDATA[One of the testers gave me a scenario where the objects get lost to a project I worked some time ago.  This happened due to the use of MouseDragElementBehavior. To explain more of the scenario, open the live link given below.  You can see the live example here [live demo]    The SOURCE CODE(.zip) is at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1146&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1146" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F04%2Fmousedragelementbehavior-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-iu%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F09%2F04%2Fmousedragelementbehavior-in-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/09/mousedragelementbehavior.png"><img class="alignnone size-full wp-image-1147" title="MouseDragElementBehavior" src="http://shamrat231.files.wordpress.com/2010/09/mousedragelementbehavior.png" alt="" width="767" height="263" /></a></p>
<p>One of the testers gave me a scenario where the objects get lost to a project I worked some time ago.  This happened due to the use of MouseDragElementBehavior. To explain more of the scenario, open the live link given below. </p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t87/" target="_blank"><span style="color:#993300;">[live demo]</span></a><span style="color:#993300;"> </span>  </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>For demonstration purpose, I will be using an one piece anime image from deviant art gallery. Starting from the left side, drag the first object out from the box and then release your mouse. You would notice that the object can not be seen anymore. This happens to be the case when you donot restrict an object in a particular bound.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/t87p1.png"><img class="alignnone size-full wp-image-1148" title="t87p1" src="http://shamrat231.files.wordpress.com/2010/09/t87p1.png" alt="" width="480" height="211" /></a></p>
<p><span style="text-decoration:underline;">MainPage.xaml<br />
</span>            &lt;Canvas x:Name=&#8221;MainHostDemo1&#8243; Background=&#8221;#b0b0b3&#8243; Width=&#8221;250&#8243; Height=&#8221;384&#8243; Margin=&#8221;20&#8243;&gt;<br />
                &lt;Canvas.Clip&gt;<br />
                    &lt;RectangleGeometry Rect=&#8221;0,0,250,384&#8243; /&gt;<br />
                &lt;/Canvas.Clip&gt;<br />
                &lt;Image Source=&#8221;Images/one-piece.jpg&#8221;&gt;<br />
                    &lt;i:Interaction.Behaviors&gt;<br />
                        &lt;ei:MouseDragElementBehavior /&gt;<br />
                    &lt;/i:Interaction.Behaviors&gt;<br />
                &lt;/Image&gt;<br />
            &lt;/Canvas&gt;</p>
<p>Now a possible solution to the problem would be to use &lt;ei:MouseDragElementBehavior ConstrainToParentBounds=&#8221;True&#8221; /&gt;. If that is the case, then try dragging the second object from the box. Notice that for object that are bigger than the restricted zone&#8230;do not works out well.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/t87p2.png"><img class="alignnone size-full wp-image-1149" title="t87p2" src="http://shamrat231.files.wordpress.com/2010/09/t87p2.png" alt="" width="480" height="211" /></a></p>
<p><span style="text-decoration:underline;">MainPage.xaml<br />
</span>            &lt;Canvas x:Name=&#8221;MainHostDemo2&#8243; Background=&#8221;#b0b0b3&#8243; Width=&#8221;250&#8243; Height=&#8221;384&#8243; Margin=&#8221;20&#8243;&gt;<br />
                &lt;Canvas.Clip&gt;<br />
                    &lt;RectangleGeometry Rect=&#8221;0,0,250,384&#8243; /&gt;<br />
                &lt;/Canvas.Clip&gt;<br />
                &lt;Image Source=&#8221;Images/one-piece.jpg&#8221;&gt;<br />
                    &lt;i:Interaction.Behaviors&gt;<br />
                        &lt;ei:MouseDragElementBehavior ConstrainToParentBounds=&#8221;True&#8221; /&gt;<br />
                    &lt;/i:Interaction.Behaviors&gt;<br />
                &lt;/Image&gt;<br />
            &lt;/Canvas&gt;</p>
<p>So basically, I will be customizing the MouseDragElementBehavior to support this kind of scenario where the objects do not get lost.</p>
<p>So let’s start by creating a custom class inheriting our default dragelementbehaviour.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/y87p3.png"><img class="alignnone size-full wp-image-1150" title="y87p3" src="http://shamrat231.files.wordpress.com/2010/09/y87p3.png" alt="" width="435" height="87" /></a></p>
<p>Now to make an object reset to its original position, I will add this new property</p>
<p>1. ResetX : This will deal with the X position that the object should get reset to. It could be the objects initial postion or at any position the user chooses to.</p>
<p>2. ResetY : This will deal with the Y position that the object should get reset to. It could be the objects initial postion or at any position the user chooses to.</p>
<p>3. AllowDropWidth : This property validate the amount of X plane that the object can move around without getting reset.</p>
<p>4. AllowDropHeight: This property validates the amount of Y plane that the object can move around without getting reset.</p>
<p>5. IsDropTargetValidate: This is a Boolean variable that determines if the object drop position needs to be validated.</p>
<p>Now let’s add this property in our CustomDragBehaviour</p>
<p>        #region ResetX<br />
        public static readonly DependencyProperty ResetXProperty = DependencyProperty<br />
            .Register(&#8220;ResetX&#8221;, typeof(double), typeof(CustomDragBehaviour), null);</p>
<p>        public double ResetX<br />
        {<br />
            get { return (double)this.GetValue(CustomDragBehaviour.ResetXProperty); }<br />
            set { this.SetValue(CustomDragBehaviour.ResetXProperty, value); }<br />
        }<br />
        #endregion</p>
<p>        #region ResetY<br />
        public static readonly DependencyProperty ResetYProperty = DependencyProperty<br />
            .Register(&#8220;ResetY&#8221;, typeof(double), typeof(CustomDragBehaviour), null);</p>
<p>        public double ResetY<br />
        {<br />
            get { return (double)this.GetValue(CustomDragBehaviour.ResetYProperty); }<br />
            set { this.SetValue(CustomDragBehaviour.ResetYProperty, value); }<br />
        }<br />
        #endregion</p>
<p>        #region AllowDropWidth<br />
        public static readonly DependencyProperty AllowDropWidthProperty = DependencyProperty<br />
            .Register(&#8220;AllowDropWidth&#8221;, typeof(double), typeof(CustomDragBehaviour), null);</p>
<p>        public double AllowDropWidth<br />
        {<br />
            get { return (double)this.GetValue(CustomDragBehaviour.AllowDropWidthProperty); }<br />
            set { this.SetValue(CustomDragBehaviour.AllowDropWidthProperty, value); }<br />
        }<br />
        #endregion</p>
<p>        #region AllowDropHeight<br />
        public static readonly DependencyProperty AllowDropHeightProperty = DependencyProperty<br />
            .Register(&#8220;AllowDropHeight&#8221;, typeof(double), typeof(CustomDragBehaviour), null);</p>
<p>        public double AllowDropHeight<br />
        {<br />
            get { return (double)this.GetValue(CustomDragBehaviour.AllowDropHeightProperty); }<br />
            set { this.SetValue(CustomDragBehaviour.AllowDropHeightProperty, value); }<br />
        }<br />
        #endregion</p>
<p>        #region IsDropTargetValidate<br />
        public static readonly DependencyProperty IsDropTargetValidateProperty = DependencyProperty<br />
            .Register(&#8220;IsDropTargetValidate&#8221;, typeof(bool), typeof(CustomDragBehaviour),null);</p>
<p>        public bool IsDropTargetValidate<br />
        {<br />
            get { return (bool)this.GetValue(CustomDragBehaviour.IsDropTargetValidateProperty); }<br />
            set { this.SetValue(CustomDragBehaviour.IsDropTargetValidateProperty, value); }<br />
        }<br />
        #endregion</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/y87p42.png"><img class="alignnone size-full wp-image-1159" title="y87p4" src="http://shamrat231.files.wordpress.com/2010/09/y87p42.png" alt="" width="870" height="130" /></a></p>
<p>Look at the above picture. I am using my new CustomDragBehaviour. I am setting IsDropTargetValidate=”true”. When the object gets out of the region, it can reset to any position that you assigned . Now allowing the amount of XY plane that the object can move around freely should be equal to the amount to the view region. So instead of giving hardcoded value, I am binding it to the parent width and height.</p>
<p>Now comes the part where we implement the moment validation rule. In this example, the validation needs to happen when the user releases the mouse. In behavior, we usually do that on two properties as shown in the code</p>
<p>        protected override void OnAttached()<br />
        {<br />
            base.OnAttached();<br />
            if (IsDropTargetValidate)<br />
                this.AssociatedObject.MouseLeftButtonUp += new MouseButtonEventHandler(AssociatedObject_MouseLeftButtonUp);<br />
        }</p>
<p>        protected override void OnDetaching()<br />
        {<br />
            base.OnDetaching();<br />
            if (IsDropTargetValidate)<br />
                this.AssociatedObject.MouseLeftButtonUp -= new MouseButtonEventHandler(AssociatedObject_MouseLeftButtonUp);<br />
        }</p>
<p>In here, I am adding an MouseLeftButtonUp handler when the object gets attached&#8230;and removing it when the objects get detached. Inside the event now apply the validation as written below. </p>
<p>        void AssociatedObject_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)<br />
        {<br />
            var img = (Image)sender;</p>
<p>            if (this.X &gt;= ResetX + AllowDropWidth || this.Y &gt;= ResetY + AllowDropHeight || this.X &lt;= -(img.ActualWidth &#8211; ResetX) || this.Y &lt;= -(img.ActualHeight &#8211; ResetY))<br />
            {<br />
                this.X = ResetX;<br />
                this.Y = ResetY;<br />
            }<br />
        }</p>
<p>For easy of setting the reset value, you could uncomment the Message written below. Change reset value to make left/right equal.</p>
<p>        void AssociatedObject_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)<br />
        {<br />
            var img = (Image)sender;</p>
<p>            //resetX and resetY value is respective to MainCanvas</p>
<p>            //&lt;il:CustomDragBehaviour ResetX=&#8221;600&#8243; ResetY=&#8221;20&#8243; /&gt;<br />
            //so +/- resetX[value] at XAML till the image moves exactly at the right boundary line. When that happens both left/right[value] will become equal.<br />
            //MessageBox.Show(X + &#8220;==&#8221; + (ResetX + AllowDropWidth)); //right validation</p>
<p>            //so +/- resetY[value] at XAML till the image moves exactly at the bottom boundary line. When that happens both left/right[value] will become equal.<br />
            //MessageBox.Show(Y + &#8220;==&#8221; + (ResetY + AllowDropHeight)); // bottom validation</p>
<p>            //no need to change here&#8230;.<br />
            if (this.X &gt;= ResetX + AllowDropWidth || this.Y &gt;= ResetY + AllowDropHeight || this.X &lt;= -(img.ActualWidth &#8211; ResetX) || this.Y &lt;= -(img.ActualHeight &#8211; ResetY))<br />
            {<br />
                this.X = ResetX;<br />
                this.Y = ResetY;<br />
            }<br />
        }</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/09/y87p5.png"><img class="alignnone size-full wp-image-1152" title="y87p5" src="http://shamrat231.files.wordpress.com/2010/09/y87p5.png" alt="" width="480" height="264" /></a></p>
<p>As always, you can download the source code from here <a href="http://www.megaupload.com/?d=ZUBRBRRU"><span style="color:#993300;">[</span><span style="color:#993300;">download link</span><span style="color:#993300;">]</span></a></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/mousedragelementbehavior/'>MouseDragElementBehavior</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1146/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1146/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1146/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1146&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/09/04/mousedragelementbehavior-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/mousedragelementbehavior.png" medium="image">
			<media:title type="html">MouseDragElementBehavior</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/t87p1.png" medium="image">
			<media:title type="html">t87p1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/t87p2.png" medium="image">
			<media:title type="html">t87p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/y87p3.png" medium="image">
			<media:title type="html">y87p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/y87p42.png" medium="image">
			<media:title type="html">y87p4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/09/y87p5.png" medium="image">
			<media:title type="html">y87p5</media:title>
		</media:content>
	</item>
		<item>
		<title>86. Multipurpose Ripple motion in Silverlight</title>
		<link>http://silverlightips.net/2010/08/31/create-multipurpose-ripple-motion-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/08/31/create-multipurpose-ripple-motion-in-silverlight/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 09:27:55 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[highlight silverlight]]></category>
		<category><![CDATA[ripple blend]]></category>
		<category><![CDATA[ripple silverlight]]></category>
		<category><![CDATA[silverlight ellipse]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1129</guid>
		<description><![CDATA[We all should be familiar with wave concept. If you throw a stone in water you can see how the motion plays out in water. I will try to create a sample animation which tries to replicate ripple motion in blend. I will not be using the ripple effect in Blend, but will create an animated [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1129&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1129" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F31%2Fcreate-multipurpose-ripple-motion-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-id%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F31%2Fcreate-multipurpose-ripple-motion-in-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/08/ripple-effect.png"><img class="alignnone size-full wp-image-1130" title="ripple-effect" src="http://shamrat231.files.wordpress.com/2010/08/ripple-effect.png" alt="" width="767" height="347" /></a></p>
<p>We all should be familiar with wave concept. If you throw a stone in water you can see how the motion plays out in water. I will try to create a sample animation which tries to replicate ripple motion in blend. I <em>will not be</em> using the <em>ripple effect in Blend</em>, but will create an animated one from scratch. This ripple is a bit different then the blend ripple effect. This ripple motion can be used for various purposes like in bing maps or giving some side effects in your site layout, some flashy click event and other times in your splash screen while showing the progress bar.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t86/" target="_blank"><span style="color:#993300;">[live demo]</span></a>   </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/blend-effect.png"><img class="alignnone size-full wp-image-1131" title="blend-effect" src="http://shamrat231.files.wordpress.com/2010/08/blend-effect.png" alt="" width="120" height="138" /></a><a href="http://shamrat231.files.wordpress.com/2010/08/blend-ripple.png"><img class="alignnone size-full wp-image-1132" title="blend-ripple" src="http://shamrat231.files.wordpress.com/2010/08/blend-ripple.png" alt="" width="135" height="135" /></a></p>
<p>Now lets look at a simple ripple picture above. The movement is from center to outward and it has like 4 circles in it. Now lets talk in terms of blend.</p>
<p>1. 4 circle ~ 4 ellipse (I will demonstrate with 3)<br />
2. Blue line ~ ellipse border<br />
3. Ripple motion ~ apply story storyboard to enlarge ellipse.</p>
<p>So basically if we create those above steps we can have a static ripple created. Lets start with the 3 circle. Each circle should be placed in such way that one is bigger than the other and should look like a ripple. Here goes the code.</p>
<p>&lt;Ellipse HorizontalAlignment=&#8221;Left&#8221; VerticalAlignment=&#8221;Stretch&#8221; Width=&#8221;118.5&#8243; Opacity=&#8221;1&#8243; Fill=&#8221;#00FFFFFF&#8221; Stroke=&#8221;#FFC4D0E3&#8243; StrokeThickness=&#8221;0&#8243; x:Name=&#8221;WaterRipple1&#8243; RenderTransformOrigin=&#8221;0.5,0.5&#8243; Grid.Column=&#8221;1&#8243; Grid.Row=&#8221;1&#8243; Height=&#8221;118.5&#8243;&gt;<br />
        &lt;/Ellipse&gt;<br />
        &lt;Ellipse HorizontalAlignment=&#8221;Left&#8221; VerticalAlignment=&#8221;Stretch&#8221; Width=&#8221;118.5&#8243; Opacity=&#8221;1&#8243; Fill=&#8221;#00FFFFFF&#8221; Stroke=&#8221;#FFC4D0E3&#8243; StrokeThickness=&#8221;0&#8243; x:Name=&#8221;WaterRipple2&#8243; RenderTransformOrigin=&#8221;0.5,0.5&#8243; Grid.Column=&#8221;1&#8243; Grid.Row=&#8221;1&#8243; Visibility=&#8221;Visible&#8221; Height=&#8221;118.5&#8243;&gt;<br />
        &lt;/Ellipse&gt;<br />
        &lt;Ellipse HorizontalAlignment=&#8221;Left&#8221; VerticalAlignment=&#8221;Stretch&#8221; Width=&#8221;50&#8243; Opacity=&#8221;1&#8243; Fill=&#8221;#00FFFFFF&#8221; Stroke=&#8221;#FFC4D0E3&#8243; StrokeThickness=&#8221;0&#8243; x:Name=&#8221;WaterRipple3&#8243; RenderTransformOrigin=&#8221;0.5,0.5&#8243; UseLayoutRounding=&#8221;False&#8221; d:LayoutRounding=&#8221;Auto&#8221; d:LayoutOverrides=&#8221;GridBox&#8221; Height=&#8221;50&#8243; Margin=&#8221;33.335,119.66,0,130.339&#8243;&gt;<br />
        &lt;/Ellipse&gt;<br />
        &lt;Ellipse HorizontalAlignment=&#8221;Left&#8221; VerticalAlignment=&#8221;Stretch&#8221; Width=&#8221;90&#8243; Opacity=&#8221;1&#8243; Fill=&#8221;#00FFFFFF&#8221; Stroke=&#8221;#FFC4D0E3&#8243; StrokeThickness=&#8221;0&#8243; x:Name=&#8221;WaterRipple4&#8243; RenderTransformOrigin=&#8221;0.5,0.5&#8243; Visibility=&#8221;Visible&#8221; Height=&#8221;90&#8243; Margin=&#8221;13,100,0,110&#8243; d:LayoutOverrides=&#8221;GridBox&#8221;&gt;<br />
        &lt;/Ellipse&gt;</p>
<p>For each ellipse, I will animate these property, so it will give an effect of enlarging and compressing. The idea is the circle will go bigger and smaller with time line.</p>
<p>1. ScaleX<br />
2. ScaleY<br />
3. TranslateX<br />
4. TranslateY<br />
5. StrokeThickness<br />
6. Opacity<br />
7. Stroke<br />
8. Fill</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/storyboard-blend.png"><img class="alignnone size-full wp-image-1133" title="storyboard-blend" src="http://shamrat231.files.wordpress.com/2010/08/storyboard-blend.png" alt="" width="549" height="303" /></a></p>
<p><strong><span style="text-decoration:underline;">Creating a control</span></strong></p>
<p>Now, after spending some quality time by manipulating I created a simple ripple effect. Now for ease of use, lets put it to a separate user control.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips3.png"><img class="alignnone size-full wp-image-1134" title="silverlight-tips" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips3.png" alt="" width="206" height="129" /></a><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs2.png"><img class="alignnone size-full wp-image-1135" title="silverlight-blogs" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs2.png" alt="" width="422" height="134" /></a></p>
<p>Now apply our newly created control on water surface. For demonstration, I will apply it in a water surface taken from a game level.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>&lt;UserControl x:Class=&#8221;Ripple.MainPage&#8221;<br />
    xmlns=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>&#8220;<br />
    xmlns:x=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>&#8220;<br />
    xmlns:d=&#8221;<a href="http://schemas.microsoft.com/expression/blend/2008">http://schemas.microsoft.com/expression/blend/2008</a>&#8220;<br />
    xmlns:mc=&#8221;<a href="http://schemas.openxmlformats.org/markup-compatibility/2006">http://schemas.openxmlformats.org/markup-compatibility/2006</a>&#8220;<br />
    xmlns:motions=&#8221;clr-namespace:Ripple&#8221;<br />
    mc:Ignorable=&#8221;d&#8221;<br />
    d:DesignHeight=&#8221;1024&#8243; d:DesignWidth=&#8221;768&#8243;&gt;<br />
    &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
        &lt;Grid Width=&#8221;768&#8243; Height=&#8221;576&#8243;&gt;<br />
            &lt;Image Source=&#8221;Images/water.png&#8221; /&gt;<br />
            &lt;motions:RippleMotion HorizontalAlignment=&#8221;Right&#8221; Margin=&#8221;0,344,220,0&#8243; VerticalAlignment=&#8221;Top&#8221; d:LayoutOverrides=&#8221;Width, Height&#8221;/&gt;<br />
            &lt;motions:RippleMotion HorizontalAlignment=&#8221;Left&#8221; Margin=&#8221;202,325,0,0&#8243; VerticalAlignment=&#8221;Top&#8221; d:LayoutOverrides=&#8221;Width, Height&#8221;/&gt;<br />
            &lt;motions:RippleMotion HorizontalAlignment=&#8221;Right&#8221; Margin=&#8221;0,290,220,0&#8243; VerticalAlignment=&#8221;Top&#8221; d:LayoutOverrides=&#8221;Width, Height&#8221;/&gt;<br />
            &lt;motions:RippleMotion Margin=&#8221;269,-71,-269,71&#8243;/&gt;<br />
            &lt;motions:RippleMotion Margin=&#8221;217,54,-217,-54&#8243; /&gt;<br />
            &lt;motions:RippleMotion Margin=&#8221;135,-71,-135,71&#8243; /&gt;<br />
        &lt;/Grid&gt;<br />
    &lt;/Grid&gt;<br />
&lt;/UserControl&gt;<br />
<a href="http://shamrat231.files.wordpress.com/2010/08/ellipse.png"><img class="alignnone size-full wp-image-1136" title="ellipse" src="http://shamrat231.files.wordpress.com/2010/08/ellipse.png" alt="" width="352" height="255" /></a></p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=JZIGDJV8" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span>   </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/highlight-silverlight/'>highlight silverlight</a>, <a href='http://silverlightips.net/tag/ripple-blend/'>ripple blend</a>, <a href='http://silverlightips.net/tag/ripple-silverlight/'>ripple silverlight</a>, <a href='http://silverlightips.net/tag/silverlight-ellipse/'>silverlight ellipse</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1129&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/08/31/create-multipurpose-ripple-motion-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/ripple-effect.png" medium="image">
			<media:title type="html">ripple-effect</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/blend-effect.png" medium="image">
			<media:title type="html">blend-effect</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/blend-ripple.png" medium="image">
			<media:title type="html">blend-ripple</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/storyboard-blend.png" medium="image">
			<media:title type="html">storyboard-blend</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips3.png" medium="image">
			<media:title type="html">silverlight-tips</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs2.png" medium="image">
			<media:title type="html">silverlight-blogs</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/ellipse.png" medium="image">
			<media:title type="html">ellipse</media:title>
		</media:content>
	</item>
		<item>
		<title>85. Custom Layout using ContentControl in Silverlight</title>
		<link>http://silverlightips.net/2010/08/24/silverlight-content-control/</link>
		<comments>http://silverlightips.net/2010/08/24/silverlight-content-control/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 06:30:57 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[custom content control]]></category>
		<category><![CDATA[silverlight content control]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1090</guid>
		<description><![CDATA[In this entry, I will use content control to create a site layout. So basically the layout control will have header, footer, left body, right body and main body. You can see the live example here [live demo]    The SOURCE CODE(.zip) is at the end of the page for download. Lets start by creating a class inheriting content [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1090&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1090" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F24%2Fsilverlight-content-control%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-hA%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F24%2Fsilverlight-content-control%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips2.png"><img class="alignnone size-full wp-image-1092" title="silverlight-tips" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips2.png" alt="" width="570" height="321" /></a></p>
<p>In this entry, I will use content control to create a site layout. So basically the layout control will have header, footer, left body, right body and main body.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t85/" target="_blank"><span style="color:#993300;">[live demo]</span></a>   </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>Lets start by creating a class inheriting content control.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/content-control.png"><img class="alignnone size-full wp-image-1093" title="content-control" src="http://shamrat231.files.wordpress.com/2010/08/content-control.png" alt="" width="537" height="174" /></a></p>
<p>namespace SiteLayout<br />
{<br />
    public class LayoutContentControl : ContentControl<br />
    {</p>
<p>    }<br />
}</p>
<p>Now before getting started with writing code, lets get the default design of the Content Control. This can easily be achieved by blend. Just drag a content control and click on “edit a copy”</p>
<p> <a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs1.png"><img class="alignnone size-full wp-image-1094" title="silverlight-blogs" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs1.png" alt="" width="329" height="385" /></a></p>
<p>Now remove the key and modify the target type to reflect your layout control as shown below.</p>
<p>        &lt;!&#8211;LayoutContentControl&#8211;&gt;<br />
&lt;Style TargetType=&#8221;controls:LayoutContentControl&#8221;&gt;<br />
            &lt;Setter Property=&#8221;Foreground&#8221; Value=&#8221;#FF000000&#8243;/&gt;<br />
            &lt;Setter Property=&#8221;HorizontalContentAlignment&#8221; Value=&#8221;Left&#8221;/&gt;<br />
            &lt;Setter Property=&#8221;VerticalContentAlignment&#8221; Value=&#8221;Top&#8221;/&gt;<br />
            &lt;Setter Property=&#8221;Template&#8221;&gt;<br />
                &lt;Setter.Value&gt;<br />
                    &lt;ControlTemplate TargetType=&#8221;controls:LayoutContentControl&#8221;&gt;<br />
                        &lt;ContentPresenter Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding Content}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; Margin=&#8221;{TemplateBinding Padding}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221;/&gt;<br />
                    ControlTemplate&gt;<br />
                &lt;/Setter.Value&gt;<br />
            &lt;/Setter&gt;<br />
        &lt;/Style&gt;</p>
<p>Now, lets get back to our LayoutContentControl class and assign the the style to our control.</p>
<p>    public class LayoutContentControl : ContentControl<br />
    {<br />
        public LayoutContentControl()<br />
        {<br />
            this.DefaultStyleKey = typeof(LayoutContentControl);<br />
        }<br />
    }</p>
<p>As stated before, I will be creating 5 sections to my layoutContentControl. So basically, five dependency property needs to be created for this class</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-template.png"><img class="alignnone size-full wp-image-1095" title="silverlight-template" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-template.png" alt="" width="471" height="250" /></a></p>
<p>So we have to have five content presenter in <span style="text-decoration:underline;">our style</span>.</p>
<p>        &lt;!&#8211;LayoutContentControl&#8211;&gt;<br />
       &lt;Style TargetType=&#8221;controls:LayoutContentControl&#8221;&gt;<br />
            &lt;Setter Property=&#8221;Foreground&#8221; Value=&#8221;#FF000000&#8243;/&gt;<br />
            &lt;Setter Property=&#8221;HorizontalContentAlignment&#8221; Value=&#8221;Left&#8221;/&gt;<br />
            &lt;Setter Property=&#8221;VerticalContentAlignment&#8221; Value=&#8221;Top&#8221;/&gt;<br />
            &lt;Setter Property=&#8221;Template&#8221;&gt;<br />
                &lt;Setter.Value&gt;<br />
                    LayoutContentControl&#8221;&gt;<br />
                        &lt;Grid&gt;<br />
                            &lt;Grid.RowDefinitions&gt;<br />
                                &lt;RowDefinition Height=&#8221;Auto&#8221;/&gt;<br />
                                &lt;RowDefinition Height=&#8221;Auto&#8221;/&gt;<br />
                                &lt;RowDefinition Height=&#8221;Auto&#8221;/&gt;<br />
                            &lt;/Grid.RowDefinitions&gt;<br />
                            &lt;ContentPresenter Grid.Row=&#8221;0&#8243; Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding Header}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; Margin=&#8221;{TemplateBinding Padding}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221;/&gt;<br />
                            &lt;Grid Grid.Row=&#8221;1&#8243;&gt;<br />
                                &lt;Grid.RowDefinitions&gt;<br />
                                    &lt;RowDefinition Height=&#8221;Auto&#8221; /&gt;<br />
                                &lt;/Grid.RowDefinitions&gt;<br />
                                &lt;Grid.ColumnDefinitions&gt;<br />
                                    &lt;ColumnDefinition Width=&#8221;.2*&#8221; /&gt;<br />
                                    &lt;ColumnDefinition Width=&#8221;.6*&#8221;/&gt;<br />
                                    &lt;ColumnDefinition Width=&#8221;.2*&#8221;/&gt;<br />
                                &lt;/Grid.ColumnDefinitions&gt;<br />
                                &lt;ContentPresenter Grid.Column=&#8221;0&#8243; Grid.Row=&#8221;0&#8243; Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding LeftBody}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; Margin=&#8221;{TemplateBinding Padding}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221;/&gt;<br />
                                &lt;ContentPresenter Grid.Column=&#8221;1&#8243; Grid.Row=&#8221;0&#8243; Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding CenterBody}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; Margin=&#8221;{TemplateBinding Padding}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221;/&gt;<br />
                                &lt;ContentPresenter Grid.Column=&#8221;2&#8243; Grid.Row=&#8221;0&#8243; Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding RightBody}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; Margin=&#8221;{TemplateBinding Padding}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221;/&gt;<br />
                            &lt;/Grid&gt;<br />
                            &lt;ContentPresenter Grid.Row=&#8221;2&#8243; Cursor=&#8221;{TemplateBinding Cursor}&#8221; ContentTemplate=&#8221;{TemplateBinding ContentTemplate}&#8221; Content=&#8221;{TemplateBinding Footer}&#8221; HorizontalAlignment=&#8221;{TemplateBinding HorizontalContentAlignment}&#8221; Margin=&#8221;{TemplateBinding Padding}&#8221; VerticalAlignment=&#8221;{TemplateBinding VerticalContentAlignment}&#8221;/&gt;<br />
                        &lt;/Grid&gt;<br />
                    &lt;/ControlTemplate&gt;<br />
                &lt;/Setter.Value&gt;<br />
            &lt;/Setter&gt;<br />
        &lt;/Style&gt;<br />
and in the class…</p>
<p><span style="text-decoration:underline;">LayoutContentControl.cs</span></p>
<p>public class LayoutContentControl : ContentControl<br />
    {<br />
        public LayoutContentControl() : base()<br />
        {<br />
            this.DefaultStyleKey = typeof(LayoutContentControl);<br />
        }</p>
<p>        public static readonly DependencyProperty HeaderProperty = DependencyProperty<br />
            .Register(&#8220;Header&#8221;, typeof(UIElement), typeof(LayoutContentControl), null);</p>
<p>        public static readonly DependencyProperty LeftBodyProperty = DependencyProperty<br />
            .Register(&#8220;LeftBody&#8221;, typeof(UIElement), typeof(LayoutContentControl), null);</p>
<p>        public static readonly DependencyProperty CenterBodyProperty = DependencyProperty<br />
            .Register(&#8220;CenterBody&#8221;, typeof(UIElement), typeof(LayoutContentControl), null);</p>
<p>        public static readonly DependencyProperty RightBodyProperty = DependencyProperty<br />
            .Register(&#8220;RightBody&#8221;, typeof(UIElement), typeof(LayoutContentControl), null);</p>
<p>        public static readonly DependencyProperty FooterProperty = DependencyProperty<br />
            .Register(&#8220;Footer&#8221;, typeof(UIElement), typeof(LayoutContentControl), null);</p>
<p>        public UIElement Header<br />
        {<br />
            get { return (UIElement)this.GetValue(LayoutContentControl.HeaderProperty); }<br />
            set { this.SetValue(LayoutContentControl.HeaderProperty, value); }<br />
        }<br />
       <br />
        public UIElement LeftBody<br />
        {<br />
            get { return (UIElement)this.GetValue(LayoutContentControl.LeftBodyProperty); }<br />
            set { this.SetValue(LayoutContentControl.LeftBodyProperty, value); }<br />
        }</p>
<p>        public UIElement RightBody<br />
        {<br />
            get { return (UIElement)this.GetValue(LayoutContentControl.RightBodyProperty); }<br />
            set { this.SetValue(LayoutContentControl.RightBodyProperty, value); }<br />
        }</p>
<p>        public UIElement CenterBody<br />
        {<br />
            get { return (UIElement)this.GetValue(LayoutContentControl.CenterBodyProperty); }<br />
            set { this.SetValue(LayoutContentControl.CenterBodyProperty, value); }<br />
        }</p>
<p>        public UIElement Footer<br />
        {<br />
            get { return (UIElement)this.GetValue(LayoutContentControl.FooterProperty); }<br />
            set { this.SetValue(LayoutContentControl.FooterProperty, value); }<br />
        }<br />
    }</p>
<p>Well, we have finished creating our own layout, now lets apply it .xaml</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-custom-control.png"><img class="alignnone size-full wp-image-1096" title="silverlight-custom-control" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-custom-control.png" alt="" width="322" height="90" /></a></p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p> &lt;controls:LayoutContentControl&gt;<br />
            &lt;controls:LayoutContentControl.Header&gt;<br />
                &lt;TextBlock Text=&#8221;Header&#8221; TextAlignment=&#8221;Center&#8221; /&gt;<br />
            &lt;/controls:LayoutContentControl.Header&gt;<br />
            &lt;controls:LayoutContentControl.LeftBody&gt;<br />
                &lt;TextBlock Text=&#8221;Left&#8221; TextAlignment=&#8221;Center&#8221; /&gt;<br />
            &lt;/controls:LayoutContentControl.LeftBody&gt;<br />
            &lt;controls:LayoutContentControl.CenterBody&gt;<br />
                &lt;TextBlock Text=&#8221;Center&#8221; TextAlignment=&#8221;Center&#8221; /&gt;<br />
            &lt;/controls:LayoutContentControl.CenterBody&gt;<br />
            &lt;controls:LayoutContentControl.RightBody&gt;<br />
                &lt;TextBlock Text=&#8221;Right&#8221; TextAlignment=&#8221;Center&#8221; /&gt;<br />
            &lt;/controls:LayoutContentControl.RightBody&gt;<br />
            &lt;controls:LayoutContentControl.Footer&gt;<br />
                &lt;TextBlock Text=&#8221;Footer&#8221; TextAlignment=&#8221;Center&#8221; /&gt;<br />
            &lt;/controls:LayoutContentControl.Footer&gt;<br />
        &lt;/controls:LayoutContentControl&gt;</p>
<p>and here is the output</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/custom-content-control.png"><img class="alignnone size-full wp-image-1097" title="custom-content-control" src="http://shamrat231.files.wordpress.com/2010/08/custom-content-control.png" alt="" width="438" height="327" /></a></p>
<p>Now, make it more like a site template by adding and customizing the content as shown in demo.</p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=M9DFGT1Y" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span>   </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/custom-content-control/'>custom content control</a>, <a href='http://silverlightips.net/tag/silverlight-content-control/'>silverlight content control</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1090/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1090/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1090/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1090/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1090/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1090/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1090/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1090/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1090&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/08/24/silverlight-content-control/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips2.png" medium="image">
			<media:title type="html">silverlight-tips</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/content-control.png" medium="image">
			<media:title type="html">content-control</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs1.png" medium="image">
			<media:title type="html">silverlight-blogs</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-template.png" medium="image">
			<media:title type="html">silverlight-template</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-custom-control.png" medium="image">
			<media:title type="html">silverlight-custom-control</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/custom-content-control.png" medium="image">
			<media:title type="html">custom-content-control</media:title>
		</media:content>
	</item>
		<item>
		<title>84. Create custom draggable Cursor like Acrobat in Silverlight</title>
		<link>http://silverlightips.net/2010/08/22/silverlight-custom-cursor/</link>
		<comments>http://silverlightips.net/2010/08/22/silverlight-custom-cursor/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 07:30:55 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[custom cursor silverlight]]></category>
		<category><![CDATA[silverlight custom cursor]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1069</guid>
		<description><![CDATA[I recently had fun with xaml cursor in blend. Anyway in this entry, I will try to show you how you can apply your own set of image cursor to your Silverlight project. For demonstration purpose, I will use the drag/hold icon of acrobat reader to make this entry a bit exciting. In acrobat, it shows two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1069&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1069" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F22%2Fsilverlight-custom-cursor%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-hf%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F22%2Fsilverlight-custom-cursor%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-custom-cursor.png"><img class="alignnone size-full wp-image-1070" title="silverlight-custom-cursor" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-custom-cursor.png" alt="" width="845" height="295" /></a></p>
<p>I recently had fun with xaml cursor in blend. Anyway in this entry, I will try to show you how you can apply your own set of image cursor to your Silverlight project. For demonstration purpose, I will use the drag/hold icon of acrobat reader to make this entry a bit exciting. In acrobat, it shows two icons. One would be “Hand” and the other would be when you press (hold) the page.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t84/" target="_blank"><span style="color:#993300;">[live demo]</span></a>   </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>Well, I am going to create exactly something like that. So lets start, first going to blend and create a draggable surface. This can be done now very easily using behavior. Lets look at our initial code.</p>
<p>&lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Gray&#8221;&gt;<br />
        &lt;Border x:Name=&#8221;PageLayout&#8221; Width=&#8221;700&#8243; CornerRadius=&#8221;2&#8243; &gt;<br />
            &lt;Canvas  x:Name=&#8221;myPage&#8221;  Margin=&#8221;10&#8243;&gt;<br />
                &lt;Border Width=&#8221;700&#8243; CornerRadius=&#8221;2&#8243; Background=&#8221;White&#8221;&gt;<br />
                    &lt;TextBlock TextWrapping=&#8221;Wrap&#8221; Margin=&#8221;50&#8243; &gt;<br />
                    amet, consectetur ais&#8230;.continues&#8221;/&gt;<br />
                &lt;/Border&gt;<br />
            &lt;/Canvas&gt;<br />
        &lt;/Border&gt;<br />
&lt;/Grid&gt;</p>
<p>The above code generates the below output. Ok, now go to behaviour section in blend and add a drag behaviour to your canvas. We are finished making our whole object draggable.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/silverlightcustomcursor1.png"><img class="alignnone size-full wp-image-1071" title="silverlightcustomcursor1" src="http://shamrat231.files.wordpress.com/2010/08/silverlightcustomcursor1.png" alt="" width="300" height="300" /></a> <a href="http://shamrat231.files.wordpress.com/2010/08/mouse-drag-element-behaviour.png"><img class="alignnone size-full wp-image-1072" title="Mouse-drag-element-behaviour" src="http://shamrat231.files.wordpress.com/2010/08/mouse-drag-element-behaviour.png" alt="" width="420" height="338" /></a></p>
<p>Now come the actual part, creating cursor. For now, I will use some picture instead of blend cursor to save time <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The idea at the moment is very simple. I will drag a picture at the same place where my cursor is. To do this, we can use the mouse move event to our advantage as shown below.</p>
<p>            InitializeComponent();<br />
            myPage.MouseMove += (s, e) =&gt; {<br />
           <br />
                Point pt = e.GetPosition(null);<br />
                customIcon.SetValue(Canvas.LeftProperty, pt.X);<br />
                customIcon.SetValue(Canvas.TopProperty, pt.Y);<br />
            };   </p>
<p>Now, the only thing left is to set the image. When the mouse enter, we want to show the “hand” icon and when the drag starts we want to show the hold icon as shown below.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/cursor_hand.png"><img class="alignnone size-full wp-image-1073" title="cursor_hand" src="http://shamrat231.files.wordpress.com/2010/08/cursor_hand.png" alt="" width="48" height="48" /></a><a href="http://shamrat231.files.wordpress.com/2010/08/cursor_drag_hand.png"><img class="alignnone size-full wp-image-1074" title="cursor_drag_hand" src="http://shamrat231.files.wordpress.com/2010/08/cursor_drag_hand.png" alt="" width="48" height="48" /></a></p>
<p>This can be easily be achieved by adding a mouse enter and press event.</p>
<p>            myPage.MouseEnter += (s, e) =&gt; {<br />
                ShowCursor(&#8220;cursor_hand.png&#8221;);<br />
            };<br />
            myPage.MouseLeave += (s, e) =&gt; {<br />
                ShowCursor(string.Empty);<br />
            };<br />
        public void ShowCursor(string imageName)<br />
        {<br />
            customIcon.Source = new BitmapImage(<br />
                new Uri(&#8220;Images/Cusors/&#8221; + imageName,<br />
                    UriKind.Relative)<br />
                );<br />
        }</p>
<p>So in the above code, the moment I am moving my cursor enter on the canvas. I am setting it default hand image and when the mouse leave the canvas remove the image. Theoretically, this should work. Now to switch between drag icon and hold icon. This could easily be done here by making changes on mouse left press event as shown below.</p>
<p>            myPage.MouseLeftButtonDown += (s, e) =&gt; {<br />
           <br />
                isPressed = true;<br />
                ShowCursor(&#8220;cursor_drag_hand.png&#8221;);<br />
            };</p>
<p>            PageLayout.MouseLeftButtonUp += (s, e) =&gt; {</p>
<p>                isPressed = false;<br />
                ShowCursor(&#8220;cursor_hand.png&#8221;);<br />
            };</p>
<p>Now the last criteria is this, the user will be moving the whole object while pressing the canvas. So we have to show the drag mouse icon as long as it is being dragged.</p>
<p>            myPage.MouseMove += (s, e) =&gt; {<br />
           <br />
                Point pt = e.GetPosition(null);<br />
                customIcon.SetValue(Canvas.LeftProperty, pt.X);<br />
                customIcon.SetValue(Canvas.TopProperty, pt.Y);</p>
<p>                if (isPressed)<br />
                    ShowCursor(&#8220;cursor_drag_hand.png&#8221;);<br />
                else<br />
                    ShowCursor(&#8220;cursor_hand.png&#8221;);<br />
            };</p>
<p>Now, once I run the page two bugs happens. One there is the default cursor and my custom cursor appears not in the correct position. The first can be fixed very easily. Set the grid and canvas cursor to none.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs.png"><img class="alignnone size-full wp-image-1075" title="silverlight-blogs" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs.png" alt="" width="523" height="89" /></a></p>
<p> and the last part is that we want to move the cursor relative to the canvas not to the Grid layout..duh!!. So make modification here</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips.png"><img class="alignnone size-full wp-image-1076" title="silverlight-tips" src="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips.png" alt="" width="448" height="84" /></a></p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=A0BEVFDF" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span>   </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/custom-cursor-silverlight/'>custom cursor silverlight</a>, <a href='http://silverlightips.net/tag/silverlight-custom-cursor/'>silverlight custom cursor</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1069/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1069&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/08/22/silverlight-custom-cursor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-custom-cursor.png" medium="image">
			<media:title type="html">silverlight-custom-cursor</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlightcustomcursor1.png" medium="image">
			<media:title type="html">silverlightcustomcursor1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/mouse-drag-element-behaviour.png" medium="image">
			<media:title type="html">Mouse-drag-element-behaviour</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/cursor_hand.png" medium="image">
			<media:title type="html">cursor_hand</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/cursor_drag_hand.png" medium="image">
			<media:title type="html">cursor_drag_hand</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-blogs.png" medium="image">
			<media:title type="html">silverlight-blogs</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/silverlight-tips.png" medium="image">
			<media:title type="html">silverlight-tips</media:title>
		</media:content>
	</item>
		<item>
		<title>83. Dynamic Left Click Context Menu in Silverlight</title>
		<link>http://silverlightips.net/2010/08/15/dynamic-silverlight-menu/</link>
		<comments>http://silverlightips.net/2010/08/15/dynamic-silverlight-menu/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 09:19:07 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[left click context menu]]></category>
		<category><![CDATA[silverlight menu]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1057</guid>
		<description><![CDATA[  The content used is for demonstration purpose. The idea is simple. Normally we handle context menu for right click event. In this entry, I will use context menu for left click event. So as it is a left click menu, then we can say that the user is actually clicking on something. You can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1057&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/08/t83p1.png"> </a><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1057" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F15%2Fdynamic-silverlight-menu%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-h3%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F15%2Fdynamic-silverlight-menu%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/08/t83p1.png"><img class="alignnone size-full wp-image-1059" title="t83p1" src="http://shamrat231.files.wordpress.com/2010/08/t83p1.png" alt="" width="800" height="130" /></a></p>
<p>The content used is for <span style="text-decoration:underline;">demonstration purpose</span>. The idea is simple. Normally we handle context menu for right click event. In this entry, I will use context menu for left click event. So as it is a left click menu, then we can say that the user is actually clicking on something.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t83/" target="_blank"><span style="color:#993300;">[live demo]</span></a><span style="color:#993300;"> </span>  </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>Lets create a simple HyperlinkButton and add a context menu.</p>
<p>    &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;White&#8221;&gt;<br />
        &lt;Image Source=&#8221;images/background.png&#8221; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Left&#8221; Stretch=&#8221;None&#8221; /&gt;<br />
        &lt;HyperlinkButton Foreground=&#8221;Black&#8221; FontSize=&#8221;12&#8243; HorizontalAlignment=&#8221;Left&#8221; IsTabStop=&#8221;False&#8221; FontWeight=&#8221;Light&#8221; Margin=&#8221;200,10,0,0&#8243; MouseEnter=&#8221;HyperlinkButton_MouseEnter&#8221; Width=&#8221;60&#8243; Height=&#8221;20&#8243; VerticalAlignment=&#8221;Top&#8221;&gt;CoolMail&lt;/HyperlinkButton&gt;<br />
        &lt;toolkit:ContextMenu x:Name=&#8221;myContextMenu&#8221; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Left&#8221; Width=&#8221;150&#8243; Visibility=&#8221;Collapsed&#8221; Margin=&#8221;205,25,0,0&#8243; /&gt;<br />
    &lt;/Grid&gt;</p>
<p>Now fill up the our context menu with some data.</p>
<p>myContextMenu.ItemsSource = new string[] { &#8220;Inbox&#8221;, &#8220;Calendar&#8221;, &#8220;Contacts&#8221;, &#8220;Send e-mail&#8221; };</p>
<p>So when the mouse over, I will show the menu and when we leave the context menu, it will hide it self. So the modified code is…</p>
<p><span style="text-decoration:underline;">MainPage.xaml.cs</span></p>
<p>    public partial class MainPage : UserControl<br />
    {<br />
        public MainPage()<br />
        {<br />
            InitializeComponent();<br />
            myContextMenu.ItemsSource = new string[] { &#8220;Inbox&#8221;, &#8220;Calendar&#8221;, &#8220;Contacts&#8221;, &#8220;Send e-mail&#8221; };<br />
            myContextMenu.MouseLeave += new MouseEventHandler(myContextMenu_MouseLeave);<br />
        }</p>
<p>        void myContextMenu_MouseLeave(object sender, MouseEventArgs e)<br />
        {<br />
            myContextMenu.Visibility = Visibility.Collapsed;<br />
        }</p>
<p>        private void HyperlinkButton_MouseEnter(object sender, MouseEventArgs e)<br />
        {<br />
            myContextMenu.Visibility = Visibility.Visible;<br />
        }<br />
    }</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t83p2.png"><img class="alignnone size-full wp-image-1060" title="t83p2" src="http://shamrat231.files.wordpress.com/2010/08/t83p2.png" alt="" width="322" height="117" /></a></p>
<p>Now this is a bit of a problem, as with dynamic menu item we happen to have no handler. In other words we have to add handlers at runtime using VisualTreeHelper. Lets add a size change handler and find our menu items.</p>
<p>myContextMenu.SizeChanged += new SizeChangedEventHandler(myContextMenu_SizeChanged);</p>
<p>I will use <a href="http://amyokabir.wordpress.com/2010/03/01/my-visualtreehelper-search-the-visual-tree/">Amyo&#8217;s visual tree helper</a> to find all the menu items</p>
<p>List&lt;MenuItem&gt; allMenuItem = GenericVisualTreeHelper.GetAllChildFrameworkElement(myContextMenu)<br />
                .Where(w =&gt; w.GetType().Equals(typeof(MenuItem))).Cast&lt;MenuItem&gt;().ToList();</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t83p3.png"><img class="alignnone size-full wp-image-1061" title="t83p3" src="http://shamrat231.files.wordpress.com/2010/08/t83p3.png" alt="" width="453" height="198" /></a></p>
<p>So we got the whole menu collection. Now lets add handler.</p>
<p>        void myContextMenu_SizeChanged(object sender, SizeChangedEventArgs e)<br />
        {<br />
            List&lt;MenuItem&gt; allMenuItem = GenericVisualTreeHelper.GetAllChildFrameworkElement(myContextMenu)<br />
                .Where(w =&gt; w.GetType().Equals(typeof(MenuItem)))<br />
                .Cast&lt;MenuItem&gt;().ToList();</p>
<p>            if (allMenuItem.Count() &gt; 0)<br />
            {<br />
                if (!eventAdded)<br />
                {<br />
                    eventAdded = true;<br />
                    foreach (var item in allMenuItem)<br />
                    {<br />
                        MenuItem menuItem = (item as MenuItem);<br />
                        if (menuItem != null)<br />
                        {<br />
                            menuItem.Click += new RoutedEventHandler(menuItem_Click);<br />
                            menuItem.MouseEnter += new MouseEventHandler(menuItem_MouseEnter);<br />
                            menuItem.MouseLeave += new MouseEventHandler(menuItem_MouseLeave);<br />
                        }<br />
                    }<br />
                }<br />
            }<br />
        }</p>
<p>In the above code, I am adding click handler for each menu items and in the below code adding some code to execute on each handler.</p>
<p>        void menuItem_MouseLeave(object sender, MouseEventArgs e)<br />
        {<br />
            MenuItem menuItem = (sender as MenuItem);<br />
            menuItem.Icon = null;<br />
        }</p>
<p>        void menuItem_MouseEnter(object sender, MouseEventArgs e)<br />
        {<br />
            MenuItem menuItem = (sender as MenuItem);<br />
            Image icon = new Image();<br />
            icon.Width = 16;<br />
            icon.Source = new BitmapImage(new Uri(&#8220;Images/menuOver.png&#8221;, UriKind.Relative));<br />
            menuItem.Icon = icon;<br />
        }</p>
<p>        void menuItem_Click(object sender, RoutedEventArgs e)<br />
        {<br />
            MenuItem menuItem = (sender as MenuItem);<br />
            MessageBox.Show(&#8220;You just clicked &#8221; + menuItem.Header);<br />
        }</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t83p4.png"><img class="alignnone size-full wp-image-1062" title="t83p4" src="http://shamrat231.files.wordpress.com/2010/08/t83p4.png" alt="" width="160" height="31" /></a></p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=KZQS22XL" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span>   </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/left-click-context-menu/'>left click context menu</a>, <a href='http://silverlightips.net/tag/silverlight-menu/'>silverlight menu</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1057/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1057/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1057/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1057/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1057/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1057/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1057/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1057/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1057&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/08/15/dynamic-silverlight-menu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t83p1.png" medium="image">
			<media:title type="html">t83p1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t83p2.png" medium="image">
			<media:title type="html">t83p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t83p3.png" medium="image">
			<media:title type="html">t83p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t83p4.png" medium="image">
			<media:title type="html">t83p4</media:title>
		</media:content>
	</item>
		<item>
		<title>82. Add DIV content over Silverlight Application</title>
		<link>http://silverlightips.net/2010/08/12/add-div-content-over-silverlight-application/</link>
		<comments>http://silverlightips.net/2010/08/12/add-div-content-over-silverlight-application/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 08:07:26 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[div silverlight]]></category>
		<category><![CDATA[silverlight localization]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1048</guid>
		<description><![CDATA[ In this entry, I will show you how to add html content over Silverlight application. For demonstration purpose, I will reuse Mike Snow localization  sample. So basically, if you change the culture at param tag, the Silverlight culture changes. Now lets add some flag in our .aspx page for both culture. Default.aspx     &#60;div id=&#8221;flags&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1048&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/08/t82p4.png"></a> <a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1048" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F12%2Fadd-div-content-over-silverlight-application%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-gU%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F12%2Fadd-div-content-over-silverlight-application%2F" height="61" width="51" /></a>
</div></a>In this entry, I will show you how to add html content over Silverlight application. For demonstration purpose, I will reuse<a href="http://www.michaelsnow.com/2010/04/28/silverlight-tip-of-the-day-7-localized-resources/"> Mike Snow localization </a> sample.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t82p1.png"><img class="alignnone size-full wp-image-1049" title="t82p1" src="http://shamrat231.files.wordpress.com/2010/08/t82p1.png" alt="" width="562" height="124" /></a></p>
<p>So basically, if you change the culture at param tag, the Silverlight culture changes. Now lets add some flag in our .aspx page for both culture.</p>
<p><span style="text-decoration:underline;">Default.aspx</span></p>
<p>    &lt;div id=&#8221;flags&#8221; style=&#8221;text-align:center&#8221;&gt;<br />
        ImageButton ID=&#8221;imgbtnen&#8221; ImageUrl=&#8221;Images/en.png&#8221; runat=&#8221;server&#8221;<br />
            Height=&#8221;16&#8243; onclick=&#8221;imgbtnen_Click&#8221; /&gt;&amp;nbsp;<br />
        ImageButton ID=&#8221;imgbtnfr&#8221; ImageUrl=&#8221;Images/fr.png&#8221; runat=&#8221;server&#8221;<br />
            Height=&#8221;16&#8243; onclick=&#8221;imgbtnfr_Click&#8221;/&gt;<br />
    &lt;/div&gt;</p>
<p>In here, I just added some flag in our .aspx page and on button click handler. I will modify the value of the param from .aspx.cs code behind as shown below</p>
<p>&lt;param id=&#8221;slculture&#8221; runat=&#8221;server&#8221; name=&#8221;uiculture&#8221; value=&#8221;en-us&#8221; /&gt;</p>
<p>Now on code level</p>
<p><span style="text-decoration:underline;">Default.aspx.cs</span></p>
<p>    public partial class _default : System.Web.UI.Page<br />
    {<br />
        protected void imgbtnen_Click(object sender, ImageClickEventArgs e)<br />
        {<br />
            slculture.Attributes.Remove(&#8220;value&#8221;);<br />
            slculture.Attributes.Add(&#8220;value&#8221;, &#8220;en-us&#8221;);<br />
        }</p>
<p>        protected void imgbtnfr_Click(object sender, ImageClickEventArgs e)<br />
        {<br />
            slculture.Attributes.Remove(&#8220;value&#8221;);<br />
            slculture.Attributes.Add(&#8220;value&#8221;, &#8220;fr-ca&#8221;);<br />
        }<br />
    }</p>
<p>Now, lets run the application.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t82p2.png"><img class="alignnone size-full wp-image-1050" title="t82p2" src="http://shamrat231.files.wordpress.com/2010/08/t82p2.png" alt="" width="595" height="187" /></a></p>
<p>Now as the title of the entry suggested, I will put the div section over my Silverlight application. Now, lets set our div to absolute position and make the Silverlight content relative.</p>
<p>&lt;div id=&#8221;flags&#8221; style=&#8221;text-align:center;position:absolute;&#8221;&gt;</p>
<p>Now if you run the application, our Silverlight app will hide the whole div section. Basically this happens because we have <span style="text-decoration:underline;">not yet</span> set our sl app to windowless true. So change the param tag to</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t82p3.png"><img class="alignnone size-full wp-image-1051" title="t82p3" src="http://shamrat231.files.wordpress.com/2010/08/t82p3.png" alt="" width="345" height="31" /></a></p>
<p>and here is the output</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t82p4.png"><img title="t82p4" src="http://shamrat231.files.wordpress.com/2010/08/t82p4.png?w=325&#038;h=204" alt="" width="325" height="204" /></a></p>
<p>As always, you can download the source code from here<span style="color:#993300;"> [</span><a href="http://www.megaupload.com/?d=WU9FSEW9" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span> </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/div-silverlight/'>div silverlight</a>, <a href='http://silverlightips.net/tag/silverlight-localization/'>silverlight localization</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1048/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1048/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1048/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1048&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/08/12/add-div-content-over-silverlight-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t82p1.png" medium="image">
			<media:title type="html">t82p1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t82p2.png" medium="image">
			<media:title type="html">t82p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t82p3.png" medium="image">
			<media:title type="html">t82p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t82p4.png" medium="image">
			<media:title type="html">t82p4</media:title>
		</media:content>
	</item>
		<item>
		<title>81. Deeply nested Path Binding using ItemsControl in Silverlight</title>
		<link>http://silverlightips.net/2010/08/08/deeply-nested-path-binding-using-itemscontrol-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/08/08/deeply-nested-path-binding-using-itemscontrol-in-silverlight/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 09:30:42 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[nested path binding]]></category>
		<category><![CDATA[silverlight datagrid]]></category>
		<category><![CDATA[silverlight datagrid binding]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=1029</guid>
		<description><![CDATA[  The idea is very simple. Lets say you received a lots of data from your BLL and the object that is returned to you is not&#8230;say simple format. By simple format, I mean that it is not easily bindable to the datagrid but most of the value that you need is nested deeper than [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1029&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p1.png"></a> <a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-1029" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F08%2Fdeeply-nested-path-binding-using-itemscontrol-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-gB%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F08%2F08%2Fdeeply-nested-path-binding-using-itemscontrol-in-silverlight%2F" height="61" width="51" /></a>
</div></a><a href="http://shamrat231.files.wordpress.com/2010/08/t81p0.png"><img class="alignnone size-full wp-image-1039" title="t81p0" src="http://shamrat231.files.wordpress.com/2010/08/t81p0.png" alt="" width="451" height="407" /></a></p>
<p>The idea is very simple. Lets say you received a lots of data from your BLL and the object that is returned to you is not&#8230;say simple format. By simple format, I mean that it is not easily bindable to the datagrid but most of the value that you need is nested deeper than the first layer of that object. </p>
<p>You can see the<strong> live example</strong> here<span style="color:#993300;"> </span><a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t81/" target="_blank"><span style="color:#993300;">[live demo]</span></a><span style="color:#993300;"> </span>  </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.   </p>
<p>In other words the object returned in not as simple as for say&#8230;</p>
<p>eg. <span style="text-decoration:underline;">Person class</span><br />
        public class Person<br />
        {<br />
            public int Id { get; set; }<br />
            public string Title { get; set; }<br />
        } </p>
<p>So now you can do two things to the returned object.<br />
1. Iterate at every level and create a collection like Person class that can easily bindable to DataGrid or…<br />
2. Bind the object as it has been returned to Datagrid and display the information that you required in DataGrid by implementing deep nested path binding </p>
<p>In this entry, I will show you how to achieve the second option without doing any kind of data manipulation from managed code to get the desired output. So for now lets start by building a scenario and then work on it to create a object. Suppose a survey has been done for ABC company on their customer and asked about what type of products they have at their home. So basically the survey is being done for say three kinds of product, Wood, Steel and Plastic (took three eg. from top of my head <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . So lets create a simple data structure. </p>
<p><span style="text-decoration:underline;">Data.cs</span> </p>
<p>public class Data<br />
    {<br />
        public int CustomerId { get; set; }<br />
        public object Wood { get; set; }<br />
        public object Steel { get; set; }<br />
        public object Plastic { get; set; }<br />
    } </p>
<p>Ok, now say on the survey , customer gave some response say wooden spoon, pencil when asked about materials they have used related to wood. At the moment, I have a public object Wood { get; set; }. So from the customer answer, I can say that, that their could be multiple response to a particular category. So lets create a object say WoodType having a List&lt;T&gt; for multiple responses. </p>
<p>    public class WoodType<br />
    {<br />
        public List&lt;Item&gt; Items { get; set; }<br />
    } </p>
<p>Where say for each item I am keeping record of the title and pulling an image related to the product. </p>
<p>    public class Item<br />
    {<br />
        public string Title { get; set; }<br />
        public BitmapImage Img { get; set; }<br />
    } </p>
<p>Now, the changed data structure of the class would be</p>
<p>    public class Data<br />
    {<br />
        public int CustomerId { get; set; }<br />
        public WoodType Wood { get; set; }<br />
        public SteelType Steel { get; set; }<br />
        public PlasticType Plastic { get; set; }<br />
    } </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p2.png"><img class="alignnone size-full wp-image-1031" title="t81p2" src="http://shamrat231.files.wordpress.com/2010/08/t81p2.png" alt="" width="163" height="114" /></a> </p>
<p>Notice, that I am actually creating a complicated object for demonstration purpose. In reality, the data structure could differ in many variations. Ok, so we are done with a simple data structure where the title is not in first layer of the object. Now I will add some feedback data and create a collection, something like this<br />
List&lt;Data&gt; entries = new List&lt;Data&gt;();<br />
entries.Add(..) </p>
<p>Anyway, look at the class below. </p>
<p>    public class FeedBackData<br />
    {<br />
        public static System.Collections.IEnumerable GetCustomerFeedBack()<br />
        {<br />
            List&lt;Data&gt; entries = new List&lt;Data&gt;(); </p>
<p>            //demonstration purpose&#8230;ideally it should follow MVVM structure<br />
            //Customer 1<br />
            entries.Add(new Data<br />
            {<br />
                CustomerId = 1,<br />
                Wood = new WoodType<br />
                {<br />
                    Items = new List&lt;Item&gt; {<br />
                    new Item { Title = &#8220;Pencil&#8221; , Img = new BitmapImage(new Uri(&#8220;Images/Wood/WoodenPencil.png&#8221;,UriKind.Relative)) },<br />
                    new Item { Title = &#8220;Wooden Spoon&#8221; , Img = new BitmapImage(new Uri(&#8220;Images/Wood/WoodenSpoon.png&#8221;,UriKind.Relative))}}<br />
                },<br />
                Steel = new SteelType<br />
                {<br />
                    Items = new List&lt;Item&gt; {<br />
                    new Item { Title = &#8220;Sword&#8221;, Img = new BitmapImage(new Uri(&#8220;Images/Steel/Sword.jpg&#8221;,UriKind.Relative)) },<br />
                    new Item { Title = &#8220;Lock&#8221;, Img = new BitmapImage(new Uri(&#8220;Images/Steel/lock.png&#8221;,UriKind.Relative)) },<br />
                    new Item { Title = &#8220;Key&#8221;, Img = new BitmapImage(new Uri(&#8220;Images/Steel/key.png&#8221;,UriKind.Relative))}}<br />
                },<br />
                Plastic = new PlasticType<br />
                {<br />
                    Items = new List&lt;Item&gt; {<br />
                    new Item { Title = &#8220;Plastic Bag&#8221;, Img = new BitmapImage(new Uri(&#8220;Images/Plastic/plasticBag.png&#8221;,UriKind.Relative))},<br />
                }<br />
                }<br />
            }); </p>
<p>            //Customer 2<br />
     // reapeat above&#8230;.<br />
            return entries;<br />
        }<br />
    } </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p3.png"><img class="alignnone size-full wp-image-1034" title="t81p3" src="http://shamrat231.files.wordpress.com/2010/08/t81p3.png" alt="" width="735" height="492" /></a></p>
<p>If you look at the above screen shot, you will see that at one level we have CustomerId and at more deeper level we have the Title and an image related to it. So we initially set out to create a complicated object to bind and at this moment we have done it. In other words, the data return is not as simple as a person class.</p>
<p>Now, how do we represent this two sets of data at different level in the object?. For this entry, I am going to <span style="text-decoration:underline;">show using Datagrid and ItemsControl</span>. Similarly, various other ways can be used to achieve the same output in Silverlight.</p>
<p>We do know that the main Data.cs has a property CustomerId, so this can easily be achieved if we add a DataGridTextColumn, some thing like this</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p5.png"><img class="alignnone size-full wp-image-1041" title="t81p5" src="http://shamrat231.files.wordpress.com/2010/08/t81p5.png" alt="" width="752" height="69" /></a></p>
<p>But for the rest, we have to use templateColumn. So lets, break the scenario, at the moment, we are getting a list of customer feedback. Those are the rows. Now we know that for each row, it is returning this</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p6.png"><img class="alignnone size-full wp-image-1042" title="t81p6" src="http://shamrat231.files.wordpress.com/2010/08/t81p6.png" alt="" width="709" height="187" /></a> </p>
<p>Ok, using the above scenario lets create a sample DataTemplate. In the above DataTemplate, we know that in the grid for each row it will return a list of Items. So add a ItemsControl and <span style="text-decoration:underline;">set the ItemSource</span> like this. </p>
<p>&lt;ItemsControl Margin=&#8221;10&#8243; ItemsSource=&#8221;{Binding Plastic.Items}&#8221;&gt; </p>
<p>So, now we now that for each Item in ItemsControl we have a Item having Title and Image. So lets bind the Titel in the ItemTemplate for the ItemsControl.  Look at the code below. </p>
<p>&lt;data:DataGridTemplateColumn Header=&#8221;Plastic&#8221;&gt;<br />
                        &lt;data:DataGridTemplateColumn.CellTemplate&gt;<br />
                            &lt;DataTemplate&gt;<br />
                                &lt;ItemsControl Margin=&#8221;10&#8243; ItemsSource=&#8221;{Binding Plastic.Items}&#8221;&gt;<br />
                                    &lt;ItemsControl.Template&gt;<br />
                                        &lt;ControlTemplate TargetType=&#8221;ItemsControl&#8221;&gt;<br />
                                            &lt;ItemsPresenter/&gt;<br />
                                        &lt;/ControlTemplate&gt;<br />
                                    &lt;/ItemsControl.Template&gt;<br />
                                    &lt;ItemsControl.ItemsPanel&gt;<br />
                                        &lt;ItemsPanelTemplate&gt;<br />
                                            &lt;StackPanel Orientation=&#8221;Vertical&#8221;/&gt;<br />
                                        &lt;/ItemsPanelTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemsPanel&gt;<br />
                                    &lt;ItemsControl.ItemTemplate&gt;<br />
                                        &lt;DataTemplate&gt;<br />
                                            &lt;TextBlock Margin=&#8221;3,3,3,0&#8243; FontSize=&#8221;12&#8243; HorizontalAlignment=&#8221;Center&#8221; Text=&#8221;{Binding Path=Title}&#8221;/&gt;<br />
                                        &lt;/DataTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemTemplate&gt;<br />
                                &lt;/ItemsControl&gt;<br />
                            &lt;/DataTemplate&gt;<br />
                        &lt;/data:DataGridTemplateColumn.CellTemplate&gt;<br />
&lt;/data:DataGridTemplateColumn&gt; </p>
<p>So basically this will follow for the rest product type. If we now bind our datagrid to the object, It will return as shown below<span style="text-decoration:underline;">.</span> </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p4.png"><img class="alignnone size-full wp-image-1037" title="t81p4" src="http://shamrat231.files.wordpress.com/2010/08/t81p4.png" alt="" width="398" height="263" /></a></p>
<p>Notice, that if a customer has multiple answers, it will show below, but on the same row. You can change the order by <span style="text-decoration:underline;">changing the orientation of ItemPanelTemplate</span>.</p>
<p>&lt;ItemsPanelTemplate&gt;<br />
 &lt;StackPanel Orientation=&#8221;Vertical&#8221;/&gt;<br />
&lt;/ItemsPanelTemplate&gt;</p>
<p>Well, the hard path is done, Now we need to modify ItemTemplate</p>
<p>&lt;ItemsControl.ItemTemplate&gt;<br />
 &lt;DataTemplate&gt;<br />
 &lt;StackPanel&gt;<br />
  &lt;Image Source=&#8221;{Binding Img}&#8221; Height=&#8221;100&#8243; /&gt;<br />
  &lt;TextBlock Margin=&#8221;3,3,3,0&#8243; FontSize=&#8221;12&#8243; HorizontalAlignment=&#8221;Center&#8221; Text=&#8221;{Binding Path=Title}&#8221; TextAlignment=&#8221;Center&#8221;/&gt;<br />
 &lt;/StackPanel&gt;<br />
 &lt;/DataTemplate&gt;<br />
&lt;/ItemsControl.ItemTemplate&gt;</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/08/t81p1.png"><img title="t81p1" src="http://shamrat231.files.wordpress.com/2010/08/t81p1.png?w=451&#038;h=627" alt="" width="451" height="627" /></a></p>
<p>The final .xaml is this</p>
<p>&lt;data:DataGrid AutoGenerateColumns=&#8221;False&#8221; Margin=&#8221;10&#8243; Name=&#8221;dg&#8221; VerticalAlignment=&#8221;Top&#8221;&gt;<br />
                &lt;data:DataGrid.Columns&gt;<br />
                    &lt;data:DataGridTextColumn Header=&#8221;CustomerId&#8221; Binding=&#8221;{Binding CustomerId}&#8221; /&gt;<br />
                    &lt;data:DataGridTemplateColumn Header=&#8221;Plastic&#8221;&gt;<br />
                        &lt;data:DataGridTemplateColumn.CellTemplate&gt;<br />
                            &lt;DataTemplate&gt;<br />
                                &lt;ItemsControl Margin=&#8221;10&#8243; ItemsSource=&#8221;{Binding Plastic.Items}&#8221;&gt;<br />
                                    &lt;ItemsControl.Template&gt;<br />
                                        &lt;ControlTemplate TargetType=&#8221;ItemsControl&#8221;&gt;<br />
                                            &lt;ItemsPresenter/&gt;<br />
                                        &lt;/ControlTemplate&gt;<br />
                                    &lt;/ItemsControl.Template&gt;<br />
                                    &lt;ItemsControl.ItemsPanel&gt;<br />
                                        &lt;ItemsPanelTemplate&gt;<br />
                                            &lt;StackPanel Orientation=&#8221;Vertical&#8221;/&gt;<br />
                                        &lt;/ItemsPanelTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemsPanel&gt;<br />
                                    &lt;ItemsControl.ItemTemplate&gt;<br />
                                        &lt;DataTemplate&gt;<br />
                                            &lt;StackPanel&gt;<br />
                                                &lt;Image Source=&#8221;{Binding Img}&#8221; Height=&#8221;100&#8243; /&gt;<br />
                                                &lt;TextBlock Margin=&#8221;3,3,3,0&#8243; FontSize=&#8221;12&#8243; HorizontalAlignment=&#8221;Center&#8221; Text=&#8221;{Binding Path=Title}&#8221; TextAlignment=&#8221;Center&#8221;/&gt;<br />
                                            &lt;/StackPanel&gt;<br />
                                        &lt;/DataTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemTemplate&gt;<br />
                                &lt;/ItemsControl&gt;<br />
                            &lt;/DataTemplate&gt;<br />
                        &lt;/data:DataGridTemplateColumn.CellTemplate&gt;<br />
                    &lt;/data:DataGridTemplateColumn&gt;<br />
                    &lt;data:DataGridTemplateColumn Header=&#8221;Wood&#8221;&gt;<br />
                        &lt;data:DataGridTemplateColumn.CellTemplate&gt;<br />
                            &lt;DataTemplate&gt;<br />
                                &lt;ItemsControl Margin=&#8221;10&#8243; ItemsSource=&#8221;{Binding Wood.Items}&#8221;&gt;<br />
                                    &lt;ItemsControl.Template&gt;<br />
                                        &lt;ControlTemplate TargetType=&#8221;ItemsControl&#8221;&gt;<br />
                                            &lt;ItemsPresenter/&gt;<br />
                                        &lt;/ControlTemplate&gt;<br />
                                    &lt;/ItemsControl.Template&gt;<br />
                                    &lt;ItemsControl.ItemsPanel&gt;<br />
                                        &lt;ItemsPanelTemplate&gt;<br />
                                            &lt;StackPanel Orientation=&#8221;Vertical&#8221;/&gt;<br />
                                        &lt;/ItemsPanelTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemsPanel&gt;<br />
                                    &lt;ItemsControl.ItemTemplate&gt;<br />
                                        &lt;DataTemplate&gt;<br />
                                            &lt;StackPanel&gt;<br />
                                                &lt;Image Source=&#8221;{Binding Img}&#8221; Height=&#8221;100&#8243; /&gt;<br />
                                                &lt;TextBlock Margin=&#8221;3,3,3,0&#8243; FontSize=&#8221;12&#8243; HorizontalAlignment=&#8221;Center&#8221; Text=&#8221;{Binding Path=Title}&#8221; TextAlignment=&#8221;Center&#8221;/&gt;<br />
                                            &lt;/StackPanel&gt;<br />
                                        &lt;/DataTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemTemplate&gt;<br />
                                &lt;/ItemsControl&gt;<br />
                            &lt;/DataTemplate&gt;<br />
                        &lt;/data:DataGridTemplateColumn.CellTemplate&gt;<br />
                    &lt;/data:DataGridTemplateColumn&gt;<br />
                    &lt;data:DataGridTemplateColumn Header=&#8221;Steel&#8221;&gt;<br />
                        &lt;data:DataGridTemplateColumn.CellTemplate&gt;<br />
                            &lt;DataTemplate&gt;<br />
                                &lt;ItemsControl Margin=&#8221;10&#8243; ItemsSource=&#8221;{Binding Steel.Items}&#8221;&gt;<br />
                                    &lt;ItemsControl.Template&gt;<br />
                                        &lt;ControlTemplate TargetType=&#8221;ItemsControl&#8221;&gt;<br />
                                            &lt;ItemsPresenter/&gt;<br />
                                        &lt;/ControlTemplate&gt;<br />
                                    &lt;/ItemsControl.Template&gt;<br />
                                    &lt;ItemsControl.ItemsPanel&gt;<br />
                                        &lt;ItemsPanelTemplate&gt;<br />
                                            &lt;StackPanel Orientation=&#8221;Vertical&#8221;/&gt;<br />
                                        &lt;/ItemsPanelTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemsPanel&gt;<br />
                                    &lt;ItemsControl.ItemTemplate&gt;<br />
                                        &lt;DataTemplate&gt;<br />
                                            &lt;StackPanel&gt;<br />
                                                &lt;Image Source=&#8221;{Binding Img}&#8221; Height=&#8221;100&#8243; /&gt;<br />
                                                &lt;TextBlock Margin=&#8221;3,3,3,0&#8243; FontSize=&#8221;12&#8243; HorizontalAlignment=&#8221;Center&#8221; Text=&#8221;{Binding Path=Title}&#8221; TextAlignment=&#8221;Center&#8221;/&gt;<br />
                                            &lt;/StackPanel&gt;<br />
                                        &lt;/DataTemplate&gt;<br />
                                    &lt;/ItemsControl.ItemTemplate&gt;<br />
                                &lt;/ItemsControl&gt;<br />
                            &lt;/DataTemplate&gt;<br />
                        &lt;/data:DataGridTemplateColumn.CellTemplate&gt;<br />
                    &lt;/data:DataGridTemplateColumn&gt;<br />
                &lt;/data:DataGrid.Columns&gt;<br />
            &lt;/data:DataGrid&gt;</p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=NDWEWC82" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span>   </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/nested-path-binding/'>nested path binding</a>, <a href='http://silverlightips.net/tag/silverlight-datagrid/'>silverlight datagrid</a>, <a href='http://silverlightips.net/tag/silverlight-datagrid-binding/'>silverlight datagrid binding</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/1029/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/1029/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/1029/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/1029/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/1029/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/1029/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/1029/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/1029/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=1029&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/08/08/deeply-nested-path-binding-using-itemscontrol-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p0.png" medium="image">
			<media:title type="html">t81p0</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p2.png" medium="image">
			<media:title type="html">t81p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p3.png" medium="image">
			<media:title type="html">t81p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p5.png" medium="image">
			<media:title type="html">t81p5</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p6.png" medium="image">
			<media:title type="html">t81p6</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p4.png" medium="image">
			<media:title type="html">t81p4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/08/t81p1.png" medium="image">
			<media:title type="html">t81p1</media:title>
		</media:content>
	</item>
		<item>
		<title>80. Wet Effect in Silverlight</title>
		<link>http://silverlightips.net/2010/07/26/wet-effect-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/07/26/wet-effect-in-silverlight/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 08:56:17 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[silverlight blogs]]></category>
		<category><![CDATA[silverlight blur effects]]></category>
		<category><![CDATA[silverlight effects]]></category>
		<category><![CDATA[silverlight tips]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=898</guid>
		<description><![CDATA[In this entry, I am going to create a wet effect using Blend in Silverlight. It is more of a trick then a tip. The idea is actually pretty simple. This will be the second effect that I am creating for my effects library. I plan to create some more effects before I put all the effects into [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=898&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"><div class="tweetmeme-button" id="tweetmeme-button-post-898" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F26%2Fwet-effect-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-eu%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F26%2Fwet-effect-in-silverlight%2F" height="61" width="51" /></a>
</div><img title="t80p7" src="http://shamrat231.files.wordpress.com/2010/07/t80p7.png?w=589&#038;h=389" alt="" width="589" height="389" /></a><a href="http://shamrat231.files.wordpress.com/2010/07/t80p1.png"></a></p>
<p>In this entry, I am going to create a wet effect using Blend in Silverlight. It is more of a trick then a tip. The idea is actually pretty simple. This will be the second effect that I am creating for my effects library. I plan to create some more effects before I put all the effects into a dll for ease of use for others. Many other things will actually follow, but for now lets create a second effect. Try start finding a picture with a wet glass effect in search engines. One example would be the one I am using&#8230;which i found in some adobe tutorial blog. <span style="text-decoration:underline;">The given text here is changeable</span> at code level. Have fun with it. </p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t80/" target="_blank"><span style="color:#993300;">[live demo]</span></a>  </p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.  </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p2.png"><img class="alignnone size-full wp-image-900" title="t80p2" src="http://shamrat231.files.wordpress.com/2010/07/t80p2.png" alt="" width="518" height="160" /></a>  </p>
<p>The above are some example that are found in search engines. Now we need another picture on which we can reside the wet effect. One such picture that i randomly picked out from the Flickr is shown below.  </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p3.png"></a> <a href="http://shamrat231.files.wordpress.com/2010/07/t80p4.png"><img class="alignnone size-full wp-image-903" title="t80p4" src="http://shamrat231.files.wordpress.com/2010/07/t80p4.png" alt="" width="317" height="119" /></a>  </p>
<p>Now comes the ordering. The one that is added last hides the other one. What is needed here is to put that wet effect on the second picture. So reduce the opacity of the crowd image.  </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p5.png"><img class="alignnone size-full wp-image-904" title="t80p5" src="http://shamrat231.files.wordpress.com/2010/07/t80p5.png" alt="" width="352" height="260" /></a>  </p>
<p>Ok, so basically we are almost done giving a wet effect. Lets add some text eg. Silverlightips.net and make the textblock center in both horizontal and vertical direction. Add some blur effect  </p>
<p><span style="text-decoration:underline;">MainPage.xaml</span>  </p>
<p>&lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
  &lt;Grid Width=&#8221;800&#8243; Height=&#8221;600&#8243;&gt;<br />
  &lt;Image Source=&#8221;/weteffect.png&#8221; Stretch=&#8221;Fill&#8221;/&gt;<br />
  &lt;Image Source=&#8221;crowd.jpg&#8221; Stretch=&#8221;Fill&#8221; Opacity=&#8221;0.2&#8243; /&gt;<br />
  &lt;TextBlock x:Name=&#8221;text&#8221; Text=&#8221;silverlightips.net&#8221; TextWrapping=&#8221;Wrap&#8221; FontSize=&#8221;96&#8243;<br />
   FontWeight=&#8221;Bold&#8221; TextAlignment=&#8221;Center&#8221; VerticalAlignment=&#8221;Center&#8221; HorizontalAlignment=&#8221;Center&#8221; RenderTransformOrigin=&#8221;0.5,0.5&#8243; FontFamily=&#8221;Lucida Handwriting&#8221;  &gt;<br />
   &lt;TextBlock.RenderTransform&gt;<br />
    &lt;CompositeTransform ScaleY=&#8221;2&#8243;/&gt;<br />
   &lt;/TextBlock.RenderTransform&gt;<br />
   &lt;TextBlock.Effect&gt;<br />
    &lt;BlurEffect Radius=&#8221;5&#8243; /&gt;<br />
   &lt;/TextBlock.Effect&gt;<br />
   &lt;TextBlock.Foreground&gt;<br />
   &lt;ImageBrush ImageSource=&#8221;crowd.jpg&#8221; Opacity=&#8221;.5&#8243; /&gt;<br />
   &lt;/TextBlock.Foreground&gt;<br />
  &lt;/TextBlock&gt;<br />
  &lt;/Grid&gt;<br />
  &lt;HyperlinkButton Content=&#8221;Samples from <a href="http://silverlightips.net">http://silverlightips.net</a> By Sharker Khaleed Mahmud&#8221; NavigateUri=&#8221;<a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Center&#8221; Height=&#8221;30&#8243; IsTabStop=&#8221;False&#8221; Foreground=&#8221;White&#8221; /&gt;<br />
 &lt;/Grid&gt;  </p>
<p>In the above code, I added some brush image on the text, gave some blur effect and placed the text above both images. Now change the pictures and the text and you can end up having your own wet effect on your text and image.  </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p1.png"><img title="t80p1" src="http://shamrat231.files.wordpress.com/2010/07/t80p1.png?w=458&#038;h=314" alt="" width="458" height="314" /></a>  </p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=FYMCDMVS" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">] </span>  </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer  </p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t80p7.png"></a></p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/silverlight-blogs/'>silverlight blogs</a>, <a href='http://silverlightips.net/tag/silverlight-blur-effects/'>silverlight blur effects</a>, <a href='http://silverlightips.net/tag/silverlight-effects/'>silverlight effects</a>, <a href='http://silverlightips.net/tag/silverlight-tips/'>silverlight tips</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/898/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/898/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/898/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=898&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/07/26/wet-effect-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t80p7.png" medium="image">
			<media:title type="html">t80p7</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t80p2.png" medium="image">
			<media:title type="html">t80p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t80p4.png" medium="image">
			<media:title type="html">t80p4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t80p5.png" medium="image">
			<media:title type="html">t80p5</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t80p1.png" medium="image">
			<media:title type="html">t80p1</media:title>
		</media:content>
	</item>
		<item>
		<title>79. Get your Gravatar Image in Silverlight</title>
		<link>http://silverlightips.net/2010/07/22/get-your-gravatar-image-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/07/22/get-your-gravatar-image-in-silverlight/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 07:35:02 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[silverlight gravatar]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=881</guid>
		<description><![CDATA[You can see the live example here [live demo] The SOURCE CODE(.zip) is at the end of the page for download. I recently visited Justin article of Silverlight COM features. If you have not read that article, I definitely recommend to have a look at it. Anyway, at the end of the page, there is a reply [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=881&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t79.png"><div class="tweetmeme-button" id="tweetmeme-button-post-881" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F22%2Fget-your-gravatar-image-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-ed%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F22%2Fget-your-gravatar-image-in-silverlight%2F" height="61" width="51" /></a>
</div><img class="alignnone size-full wp-image-882" title="t79" src="http://shamrat231.files.wordpress.com/2010/07/t79.png" alt="" width="293" height="256" /></a></p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t79/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>I recently visited Justin article of <a href="http://justinangel.net/CuttingEdgeSilverlight4ComFeatures">Silverlight COM features</a>. If you have not read that article, I definitely recommend to have a look at it. Anyway, at the <span style="text-decoration:underline;">end of the page</span>, there is a reply section. When you type your email address, it gets your avatar. The whole site is in Silverlight.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t79p2.png"><img class="alignnone size-full wp-image-883" title="t79p2" src="http://shamrat231.files.wordpress.com/2010/07/t79p2.png" alt="" width="452" height="186" /></a></p>
<p>In this entry, I will show you, how to do that for your Silverlight application. According to gravatar site, you need to create a MD5 hash. All URLs on Gravatar are based on the use of the hashed value of an email address. Images and profiles are both accessed via the hash of an email, and it is considered the primary way of identifying an identity within the system. To ensure a consistent and accurate hash, the following steps should be taken to create a hash:</p>
<p>1.Trim leading and trailing whitespace from an email address<br />
2.Force all characters to lower-case<br />
3.md5 hash the final string</p>
<p>Great, so basically, if I do the above three steps, I am good to go. You can get your <a href="http://code.msdn.microsoft.com/SilverlightMD5/Wiki/View.aspx?title=MD5Core">MD5 class</a> here by Reid Borsuk and Jenny Zheng.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t79p3.png"><img class="alignnone size-full wp-image-886" title="t79p3" src="http://shamrat231.files.wordpress.com/2010/07/t79p3.png" alt="" width="184" height="292" /></a></p>
<p>Now at code level, all that is required is on button click event to generate an url…something like this</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t79p4.png"><img class="alignnone size-full wp-image-887" title="t79p4" src="http://shamrat231.files.wordpress.com/2010/07/t79p4.png" alt="" width="488" height="191" /></a></p>
<p>Lets go at code level and use the MD5 class to generate a proper url for the image control.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>    public partial class MainPage : UserControl<br />
    {<br />
        public MainPage()<br />
        {<br />
            InitializeComponent();<br />
            Loaded += (s, e) =&gt; {<br />
                tbEmailAddress.Text = &#8220;<a href="mailto:smiley@smiley.com">sample@sample.com</a>&#8220;;<br />
            };<br />
        }</p>
<p>        private string GetUrl()<br />
        {</p>
<p>            //Jeff Wilcox wpf class code&#8230;.<br />
            StringBuilder sb = new StringBuilder();<br />
            byte[] text = Encoding.UTF8.GetBytes(tbEmailAddress.Text.ToLower().Trim());<br />
            byte[] md5hash = new MD5Managed().ComputeHash(text);</p>
<p>            foreach (byte b in md5hash)<br />
            {<br />
                sb.Append(b.ToString(&#8220;X2&#8243;));<br />
            }  </p>
<p>            return sb.ToString();<br />
        }</p>
<p>        private void Button_Click(object sender, RoutedEventArgs e)<br />
        {<br />
            string url = &#8220;<a href="http://www.gravatar.com/avatar/">http://www.gravatar.com/avatar/</a>&#8221; + GetUrl().ToLower() + &#8220;.jpg&#8221;;<br />
            imgGravatar.Source = new BitmapImage(<br />
                    new Uri(url, UriKind.Absolute));<br />
        }<br />
    }</p>
<p>In the above code, the email address is being converted to MD5 hash and a url is being generated. That url is being assigned to the Image control.</p>
<p>Now, run the .aspx page.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t79p5.png"><img class="alignnone size-full wp-image-888" title="t79p5" src="http://shamrat231.files.wordpress.com/2010/07/t79p5.png" alt="" width="329" height="298" /></a></p>
<p>As always, you can download the source code from here<span style="color:#993300;"> [</span><a href="http://www.megaupload.com/?d=RSVZEXGQ" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">] </span></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/silverlight-gravatar/'>silverlight gravatar</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/881/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/881/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/881/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/881/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/881/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/881/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/881/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/881/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=881&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/07/22/get-your-gravatar-image-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t79.png" medium="image">
			<media:title type="html">t79</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t79p2.png" medium="image">
			<media:title type="html">t79p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t79p3.png" medium="image">
			<media:title type="html">t79p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t79p4.png" medium="image">
			<media:title type="html">t79p4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t79p5.png" medium="image">
			<media:title type="html">t79p5</media:title>
		</media:content>
	</item>
		<item>
		<title>78. How do I create a simple Image Slider in Silverlight</title>
		<link>http://silverlightips.net/2010/07/21/how-do-i-create-a-simple-image-slider-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/07/21/how-do-i-create-a-simple-image-slider-in-silverlight/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 04:32:02 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[image previous next]]></category>
		<category><![CDATA[image slide]]></category>
		<category><![CDATA[image slider]]></category>
		<category><![CDATA[Photo viewer]]></category>
		<category><![CDATA[picture viewer]]></category>
		<category><![CDATA[Silverlight Image Viewer]]></category>
		<category><![CDATA[slide image]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=871</guid>
		<description><![CDATA[I will continue with my previous post next week. In the mean time, I will show you how to create a simple image slider. Basically a slider or tray of image can be used in many different scenarios. One common example would be IMDB slide show. Currently it has post back for every image. Anyway, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=871&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t78.png"><div class="tweetmeme-button" id="tweetmeme-button-post-871" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F21%2Fhow-do-i-create-a-simple-image-slider-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-e3%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F21%2Fhow-do-i-create-a-simple-image-slider-in-silverlight%2F" height="61" width="51" /></a>
</div><img class="alignnone size-full wp-image-872" title="t78" src="http://shamrat231.files.wordpress.com/2010/07/t78.png" alt="" width="670" height="400" /></a></p>
<p>I will continue with my previous post next week. In the mean time, I will show you how to create a simple image slider. Basically a slider or tray of image can be used in many different scenarios. One common example would be IMDB slide show. Currently it has post back for every image. Anyway, I am going create a sliding image using deviant art gallery examples for demonstration purpose.</p>
<p>First of all, there are two ways we can integrate sliding behavior. One option would be to animate through Storyboard from Expression Blend. Another one is to do it using managed code from C#. The latter one is a bit trickier, but that is the one I will code for this scenario.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t78/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t78p1.png"><img class="alignnone size-full wp-image-873" title="t78p1" src="http://shamrat231.files.wordpress.com/2010/07/t78p1.png" alt="" width="727" height="158" /></a></p>
<p>A basic slide show needs to have a &lt; previous and a next &gt; image. Current version of Silverlight Image control do not support click event. So I will use HyperlinkButton as shown above.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>        &lt;StackPanel Orientation=&#8221;Horizontal&#8221; VerticalAlignment=&#8221;Center&#8221;&gt;<br />
            &lt;HyperlinkButton&gt;<br />
                &lt;HyperlinkButton.Content&gt;<br />
                    &lt;Image Source=&#8221;Images/previous.png&#8221; Width=&#8221;128&#8243; /&gt;<br />
                HyperlinkButton.Content&gt;<br />
            &lt;/HyperlinkButton&gt;<br />
            &lt;StackPanel Orientation=&#8221;Horizontal&#8221; Width=&#8221;500&#8243;&gt;<br />
                Image….<br />
            StackPanel&gt;<br />
            &lt;HyperlinkButton&gt;<br />
                &lt;HyperlinkButton.Content&gt;<br />
                    &lt;Image Source=&#8221;Images/next.png&#8221; Width=&#8221;128&#8243; /&gt;<br />
                &lt;/HyperlinkButton.Content&gt;<br />
            &lt;/HyperlinkButton&gt;<br />
        StackPanel&gt;</p>
<p>Now let’s put some image in the above code. The main idea is that I will try to slide the whole image collection while always showing one image per slide. For this to work, there are two things that need to be done.</p>
<p>First of all, the portion that the user should see from the collection be a canvas with 500 width. So basically, at all times, any image that will be shown from the Stackpanel will be in the canvas control and rest will automatically get cut if it exceeds the clipping. Next thing that I have to do is to add a simple sliding effect here. For this purpose, I will modify translate X coordinates for PanelHost from code level. So the code at xaml becomes like this.</p>
<p>            &lt;Canvas x:Name=&#8221;MainFrame&#8221; Background=&#8221;AntiqueWhite&#8221; Margin=&#8221;0,-200,600,0&#8243;&gt;<br />
                &lt;Canvas.Clip&gt;<br />
                    &lt;RectangleGeometry RadiusX=&#8221;10&#8243; RadiusY=&#8221;10&#8243; Rect=&#8221;0,0,600,500&#8243; /&gt;<br />
                &lt;/Canvas.Clip&gt;<br />
                &lt;StackPanel x:Name=&#8221;PanelHost&#8221; Orientation=&#8221;Horizontal&#8221; Height=&#8221;500&#8243;&gt;<br />
                    &lt;StackPanel.RenderTransform&gt;<br />
                        &lt;TranslateTransform X=&#8221;0&#8243; Y=&#8221;0&#8243; x:Name=&#8221;ScaleMove&#8221; /&gt;<br />
                    &lt;/StackPanel.RenderTransform&gt;<br />
                    &lt;Image Source=&#8221;Images/Atlantis_by_RaVirr17.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243;/&gt;<br />
                    &lt;Image Source=&#8221;Images/in_our_rainbow_by_WolfRoad.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243;/&gt;<br />
                    &lt;Image Source=&#8221;Images/bda5f23dc0d4364c0d862123c5ffc826.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243; /&gt;<br />
                    &lt;Image Source=&#8221;Images/Wings_of_Time__One__by_selenart.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243; /&gt;<br />
                &lt;/StackPanel&gt;<br />
            &lt;/Canvas&gt;</p>
<p>Ok, lets create a sliding storyboard from code behind.</p>
<p><span style="text-decoration:underline;">Animation.cs</span></p>
<p>    public class Animation<br />
    {<br />
public static Storyboard SlideImageEffect(UIElement controlToAnimate, double positionToMove)<br />
        {<br />
            DoubleAnimation da = new DoubleAnimation();<br />
            da.Duration = new Duration(TimeSpan.FromSeconds(1));</p>
<p>            Storyboard sb = new Storyboard();<br />
            sb.Duration = new Duration(TimeSpan.FromSeconds(1));<br />
            sb.Children.Add(da);</p>
<p>            Storyboard.SetTarget(da, controlToAnimate);<br />
            Storyboard.SetTargetProperty(da, new PropertyPath(&#8220;(UIElement.RenderTransform).(TranslateTransform.X)&#8221;));<br />
            da.To = positionToMove;<br />
            return sb;<br />
        }<br />
    }</p>
<p>Now call this managed code storyboard like this</p>
<p><span style="text-decoration:underline;">MainPage.xaml.cs</span></p>
<p>    public partial class MainPage : UserControl<br />
    {<br />
        int imgSlide = 0;<br />
        int noimgMoved = 1;<br />
        public MainPage()<br />
        {<br />
            InitializeComponent();<br />
        }</p>
<p>        private void Back_Click(object sender, RoutedEventArgs e)<br />
        {<br />
            if (noimgMoved != 1)<br />
            {<br />
                noimgMoved&#8211;;<br />
                imgSlide += 600;<br />
                Animation.SlideImageEffect(this.PanelHost, imgSlide).Begin();<br />
            }<br />
        }</p>
<p>        private void Next_Click(object sender, RoutedEventArgs e)<br />
        {<br />
            if (PanelHost.Children.Count != noimgMoved)<br />
            {<br />
                noimgMoved++;<br />
                imgSlide -= 600;<br />
                Animation.SlideImageEffect(this.PanelHost, imgSlide).Begin();<br />
            }<br />
        }<br />
    }</p>
<p>In the above code, I am keeping track of no of image moved and how much translate has been made to the current stackpanel. By default I have set my main view width to 600. So every time it slides, it adds or remove the fixed width from the translate X position.</p>
<p>So the final markup of the MainPage.xaml is like this</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>&lt;UserControl x:Class=&#8221;Tips.MainPage&#8221;<br />
    xmlns=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>&#8220;<br />
    xmlns:x=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>&#8220;<br />
    xmlns:d=&#8221;<a href="http://schemas.microsoft.com/expression/blend/2008">http://schemas.microsoft.com/expression/blend/2008</a>&#8220;<br />
    xmlns:mc=&#8221;<a href="http://schemas.openxmlformats.org/markup-compatibility/2006">http://schemas.openxmlformats.org/markup-compatibility/2006</a>&#8220;<br />
    mc:Ignorable=&#8221;d&#8221;<br />
    d:DesignHeight=&#8221;300&#8243; d:DesignWidth=&#8221;1000&#8243;&gt;<br />
    &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
        &lt;StackPanel Orientation=&#8221;Horizontal&#8221; VerticalAlignment=&#8221;Center&#8221; HorizontalAlignment=&#8221;Center&#8221;&gt;<br />
            &lt;HyperlinkButton VerticalAlignment=&#8221;Center&#8221; Click=&#8221;Back_Click&#8221; IsTabStop=&#8221;False&#8221;&gt;<br />
                &lt;HyperlinkButton.Content&gt;<br />
                    &lt;Image Source=&#8221;Images/previous.png&#8221; Width=&#8221;128&#8243; /&gt;<br />
                &lt;/HyperlinkButton.Content&gt;<br />
            &lt;/HyperlinkButton&gt;<br />
            &lt;Canvas x:Name=&#8221;MainFrame&#8221; Background=&#8221;AntiqueWhite&#8221; Margin=&#8221;0,-200,600,0&#8243;&gt;<br />
                &lt;Canvas.Clip&gt;<br />
                    &lt;RectangleGeometry RadiusX=&#8221;10&#8243; RadiusY=&#8221;10&#8243; Rect=&#8221;0,0,600,500&#8243; /&gt;<br />
                &lt;/Canvas.Clip&gt;<br />
                &lt;StackPanel x:Name=&#8221;PanelHost&#8221; Orientation=&#8221;Horizontal&#8221; Height=&#8221;500&#8243;&gt;<br />
                    &lt;StackPanel.RenderTransform&gt;<br />
                        &lt;TranslateTransform X=&#8221;0&#8243; Y=&#8221;0&#8243; x:Name=&#8221;ScaleMove&#8221; /&gt;<br />
                    &lt;/StackPanel.RenderTransform&gt;<br />
                    &lt;Image Source=&#8221;Images/Atlantis_by_RaVirr17.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243;/&gt;<br />
                    &lt;Image Source=&#8221;Images/in_our_rainbow_by_WolfRoad.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243;/&gt;<br />
                    &lt;Image Source=&#8221;Images/bda5f23dc0d4364c0d862123c5ffc826.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243; /&gt;<br />
                    &lt;Image Source=&#8221;Images/Wings_of_Time__One__by_selenart.jpg&#8221; Stretch=&#8221;Fill&#8221; Width=&#8221;600&#8243; /&gt;<br />
                &lt;/StackPanel&gt;<br />
            &lt;/Canvas&gt;<br />
            &lt;HyperlinkButton VerticalAlignment=&#8221;Center&#8221; Click=&#8221;Next_Click&#8221; IsTabStop=&#8221;False&#8221;&gt;<br />
                &lt;HyperlinkButton.Content&gt;<br />
                    &lt;Image Source=&#8221;Images/next.png&#8221; Width=&#8221;128&#8243; /&gt;<br />
                &lt;/HyperlinkButton.Content&gt;<br />
            &lt;/HyperlinkButton&gt;<br />
        &lt;/StackPanel&gt;<br />
        &lt;HyperlinkButton Content=&#8221;Samples from <a href="http://silverlightips.net">http://silverlightips.net</a> by Sharker Khaleed Mahmud&#8221; NavigateUri=&#8221;<a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; Height=&#8221;30&#8243; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Center&#8221; IsTabStop=&#8221;False&#8221;/&gt;<br />
    &lt;/Grid&gt;<br />
&lt;/UserControl&gt;</p>
<p>I will continue more with this topic in next entry by adding other stuffs before going back to PhotoShop effects library.</p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=3JMKL1B9" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">] </span></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/image-previous-next/'>image previous next</a>, <a href='http://silverlightips.net/tag/image-slide/'>image slide</a>, <a href='http://silverlightips.net/tag/image-slider/'>image slider</a>, <a href='http://silverlightips.net/tag/photo-viewer/'>Photo viewer</a>, <a href='http://silverlightips.net/tag/picture-viewer/'>picture viewer</a>, <a href='http://silverlightips.net/tag/silverlight-image-viewer/'>Silverlight Image Viewer</a>, <a href='http://silverlightips.net/tag/slide-image/'>slide image</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/871/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=871&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/07/21/how-do-i-create-a-simple-image-slider-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t78.png" medium="image">
			<media:title type="html">t78</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t78p1.png" medium="image">
			<media:title type="html">t78p1</media:title>
		</media:content>
	</item>
		<item>
		<title>77. Apply Clipping on Photoshop Brush Effects in Silverlight</title>
		<link>http://silverlightips.net/2010/07/19/photoshop-brush-effects-clipping-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/07/19/photoshop-brush-effects-clipping-in-silverlight/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 09:25:04 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[clip silverlight]]></category>
		<category><![CDATA[image clipping silverlight]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=844</guid>
		<description><![CDATA[In this entry, I tried to create a sparkling smiley. The beauty of this sample is that all you need to do is replace two images. All the hard work has been done in the sample source code and is to be explained below. Replace the two images on the project and you will have your own sets [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=844&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t77p1.png"><div class="tweetmeme-button" id="tweetmeme-button-post-844" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F19%2Fphotoshop-brush-effects-clipping-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-dC%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F19%2Fphotoshop-brush-effects-clipping-in-silverlight%2F" height="61" width="51" /></a>
</div><img class="alignnone size-full wp-image-845" title="t77p1" src="http://shamrat231.files.wordpress.com/2010/07/t77p1.png" alt="" width="659" height="407" /></a></p>
<p>In this entry, I tried to create a sparkling smiley. The beauty of this sample is that all you need to do is replace <span style="text-decoration:underline;">two images</span>. All the hard work has been done in the sample source code and is to be explained below. Replace the two images on the project and you will have your own sets of broken effects applied on those images. If you have read my <a href="http://silverlightips.net/2010/07/18/working-with-photoshop-brush-effects-in-silverlight/">previous post</a> you will see that I have ended up creating a broken mirror. One basic flaw with that mirror effect is that when a glass breaks, it usually does not show black edges on every crack effect. Now let’s start by changing that.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t77/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>To invert the photo negative of an image for expression media</p>
<p>1. Select an image file.</p>
<p>2. On the Window menu, click Image Editor.</p>
<p>3. Click the Invert Photo Negative filter.</p>
<p>4. In the Invert Photo Negative dialog box, click OK to invert the image.</p>
<p>or if you have Adobe Photoshop, just press CTRL+I. Enlarge the crack area. If your look at the mirror image, it has more height than width. So in this case, I will rotate it and clip the background floor.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t77p2.png"><img class="alignnone size-full wp-image-846" title="t77p2" src="http://shamrat231.files.wordpress.com/2010/07/t77p2.png" alt="" width="434" height="253" /></a></p>
<p>If you want to change the mirror picture you can replace with different picture. So far, the total code generated is this</p>
<p><strong><span style="text-decoration:underline;">MainPage.xaml.cs</span></strong></p>
<p> &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
  &lt;Image Source=&#8221;Mirror_by_audpod.jpg&#8221; Stretch=&#8221;Uniform&#8221; RenderTransformOrigin=&#8221;0.5,0.5&#8243; Margin=&#8221;50&#8243;&gt;<br />
    &lt;Image.RenderTransform&gt;<br />
     &lt;CompositeTransform Rotation=&#8221;-90&#8243;/&gt;<br />
    &lt;/Image.RenderTransform&gt;<br />
   &lt;/Image&gt;<br />
   &lt;Image x:Name=&#8221;unique_psds&#8221; Source=&#8221;Photoshop-Brushes-Broken-Glass-psd9371_Images/unique_psds.png&#8221; RenderTransformOrigin=&#8221;0.5,0.5&#8243; UseLayoutRounding=&#8221;False&#8221; d:LayoutRounding=&#8221;Auto&#8221; Canvas.Left=&#8221;131&#8243; Canvas.Top=&#8221;-250&#8243; Margin=&#8221;33.89,186.357,46.006,188.643&#8243; Height=&#8221;330&#8243;&gt;<br />
    &lt;Image.RenderTransform&gt;<br />
     &lt;CompositeTransform Rotation=&#8221;-29.704&#8243;/&gt;<br />
    &lt;/Image.RenderTransform&gt;<br />
    &lt;Image.Projection&gt;<br />
     &lt;PlaneProjection/&gt;<br />
    &lt;/Image.Projection&gt;<br />
   &lt;/Image&gt;<br />
  &lt;HyperlinkButton Content=&#8221;Samples from <a href="http://silverlightips.net">http://silverlightips.net</a> by Sharker Khaleed Mahmud&#8221; NavigateUri=&#8221;<a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; IsTabStop=&#8221;False&#8221; Foreground=&#8221;White&#8221; HorizontalAlignment=&#8221;Center&#8221; Height=&#8221;30&#8243; VerticalAlignment=&#8221;Top&#8221;/&gt;<br />
 &lt;/Grid&gt;</p>
<p>Now i will try to show Wonderland world inside the crack. The idea  of creating crack is explained at earlier post. I will try to show &#8221;Alice in Wonderland&#8221; scenary inside the crack. To do that, I will create a path around the area of the crack. This can be done by creating several lines and making them into a simple path or just draw a path with many connecting nodes.</p>
<p> <a href="http://shamrat231.files.wordpress.com/2010/07/t77p4.png"><img class="alignnone size-full wp-image-848" title="t77p4" src="http://shamrat231.files.wordpress.com/2010/07/t77p4.png" alt="" width="461" height="225" /></a> <a href="http://shamrat231.files.wordpress.com/2010/07/t77p3.png"><img class="alignnone size-full wp-image-847" title="t77p3" src="http://shamrat231.files.wordpress.com/2010/07/t77p3.png" alt="" width="158" height="91" /></a></p>
<p>Make sure that you have put your stroke color white when you draw the line on the crack region. So above you can see the output path generated. Now I will add a wonderland picture to the project and clip it using the path.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t77p5.png"><img class="alignnone size-full wp-image-849" title="t77p5" src="http://shamrat231.files.wordpress.com/2010/07/t77p5.png" alt="" width="495" height="258" /></a>   <a href="http://shamrat231.files.wordpress.com/2010/07/t77p6.png"><img class="alignnone size-full wp-image-850" title="t77p6" src="http://shamrat231.files.wordpress.com/2010/07/t77p6.png" alt="" width="212" height="283" /></a></p>
<p>And you have the output like this. The final output of the code is</p>
<p><strong><span style="text-decoration:underline;">MainPage.xaml (modified)</span></strong></p>
<p><strong></strong><br />
 &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
  &lt;Canvas Width=&#8221;960&#8243; Height=&#8221;500&#8243;&gt;<br />
   &lt;Image Source=&#8221;Mirror_by_audpod.jpg&#8221; Stretch=&#8221;Uniform&#8221; Canvas.Left=&#8221;199&#8243; Canvas.Top=&#8221;-36&#8243; /&gt;<br />
   &lt;Image Source=&#8221;alice-in-wonderland2-lst066214.jpg&#8221; Stretch=&#8221;Fill&#8221; Canvas.Top=&#8221;102&#8243; Width=&#8221;649&#8243; Canvas.Left=&#8221;27&#8243; Height=&#8221;467&#8243; Clip=&#8221;M366,171.5 L371,163.5 L375,167 L381.5,167 L388,161.5 L393.25,170 L404,171.5 L408,169.75 L410.75,165.25 L411,159 L412.5,147.25 L414,138 L416.75,143.25 L420.25,151.75 L422,158.75 L423.25,165.75 L425.75,170.5 L430.5,174 L432,178.5 L433,181.5 L436.75,186.25 L440.5,190 L447,193.75 L455.5,195 L467.25,196.25 L468.52155,196.28854 L475.5,196.5 L485.75,197.75 L497.25,199 L511,200 L522.75,201 L529.69897,200.40439 L539.42041,199.57111 L540.25,199.5 L558.75,200 L562,197.75 L563.25,196.25 L562.25,191.25 L566.75,191.75 L571,191.25 L574.5,186 L574,182.75 L569.25,176.75 L571.5,175.75 L573.25,174.5 L577,174 L581.5,176 L586.5,175 L591,176.75 L597,177 L603.5,174.75 L608.75,169.75 L612.75,166 L614.5,172.5 L616.25,177.75 L620,179.75 L625.5,178.5 L630.5,178 L633,177.25 L628.25,182.25 L621.25,191 L619.25,194 L616,196.5 L613,206.75 L615.5,215.25 L613,221 L608.5,226.25 L605.5,228.75 L598.75,217.75 L595.5,210.75 L589.75,209 L583.5,209.75 L579,208 L576.5,203.5 L572.5,203 L568.25,205.75 L565.25,207.25 L562.25,207.5 L559.5,205.75 L558,202.25 L466.25,199.75 L464.5,200.75 L461.25,204.75 L458.75,208 L458.5,209.75 L457,213.25 L458.75,218.75 L462.5,221.75 L466.5,225.5 L471.75,228 L474,230.5 L466.75,231.5 L454.75,232 L444.5,232.25 L439,229.25 L435,230 L429.25,232.75 L423.25,235.75 L418.25,238 L415.5,244 L413,248.75 L407.5,250.25 L400.75,251 L392,251.75 L386,251 L387.5,245 L389.75,238.5 L393.75,229.25 L396,222.75 L396.5,213.75 L392.25,210 L388.75,205.75 L384.75,205 L383.5,198.75 L386,191.5 L387.25,187.75 L379.25,183.75 L368.75,181 L357.25,179 L366,177.5 L368,175.5 z&#8221;/&gt;<br />
   &lt;Image x:Name=&#8221;unique_psds&#8221; Source=&#8221;Photoshop-Brushes-Broken-Glass-psd9371_Images/unique_psds.png&#8221; RenderTransformOrigin=&#8221;0.5,0.5&#8243; UseLayoutRounding=&#8221;False&#8221; d:LayoutRounding=&#8221;Auto&#8221; Canvas.Left=&#8221;237&#8243; Canvas.Top=&#8221;145&#8243; Width=&#8221;400&#8243; Height=&#8221;300&#8243;&gt;<br />
    &lt;Image.RenderTransform&gt;<br />
     &lt;CompositeTransform Rotation=&#8221;-29.704&#8243;/&gt;<br />
    &lt;/Image.RenderTransform&gt;<br />
    &lt;Image.Projection&gt;<br />
     &lt;PlaneProjection/&gt;<br />
    &lt;/Image.Projection&gt;<br />
   &lt;/Image&gt;<br />
   &lt;Image x:Name=&#8221;unique_psds_Copy&#8221; Source=&#8221;Photoshop-Brushes-Broken-Glass-psd9371_Images/unique_psds.png&#8221; RenderTransformOrigin=&#8221;0.5,0.5&#8243; UseLayoutRounding=&#8221;False&#8221; d:LayoutRounding=&#8221;Auto&#8221; Width=&#8221;245.028&#8243; HorizontalAlignment=&#8221;Right&#8221; Canvas.Left=&#8221;397&#8243; Canvas.Top=&#8221;278&#8243;&gt;<br />
    &lt;Image.RenderTransform&gt;<br />
     &lt;CompositeTransform Rotation=&#8221;-79.637&#8243;/&gt;<br />
    &lt;/Image.RenderTransform&gt;<br />
    &lt;Image.Projection&gt;<br />
     &lt;PlaneProjection/&gt;<br />
    &lt;/Image.Projection&gt;<br />
   &lt;/Image&gt;<br />
  &lt;/Canvas&gt;<br />
  &lt;HyperlinkButton Content=&#8221;Samples from <a href="http://silverlightips.net">http://silverlightips.net</a> by Sharker Khaleed Mahmud&#8221; NavigateUri=&#8221;<a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; IsTabStop=&#8221;False&#8221; Foreground=&#8221;White&#8221; HorizontalAlignment=&#8221;Center&#8221; Height=&#8221;30&#8243; VerticalAlignment=&#8221;Top&#8221;/&gt;<br />
 &lt;/Grid&gt;<br />
<a href="http://shamrat231.files.wordpress.com/2010/07/t77p7.png"><img class="alignnone size-full wp-image-851" title="t77p7" src="http://shamrat231.files.wordpress.com/2010/07/t77p7.png" alt="" width="515" height="272" /></a></p>
<p>Now, add a suitable image behind your broken effect as shown in the top picture of this blog post. I took that picture from deviantart gallery for demonstration purpose. Then apply the output created so far. Next entry will deal more about creating seperate independent effects library.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t76p8.png"><img class="alignnone size-full wp-image-867" title="t76p8" src="http://shamrat231.files.wordpress.com/2010/07/t76p8.png" alt="" width="183" height="150" /></a></p>
<p>As always, you can download the source code from here<span style="color:#993300;"> [</span><a href="http://www.megaupload.com/?d=3ESQDWPX" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">] </span></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/clip-silverlight/'>clip silverlight</a>, <a href='http://silverlightips.net/tag/image-clipping-silverlight/'>image clipping silverlight</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/844/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/844/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/844/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/844/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/844/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/844/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/844/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/844/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=844&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/07/19/photoshop-brush-effects-clipping-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p1.png" medium="image">
			<media:title type="html">t77p1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p2.png" medium="image">
			<media:title type="html">t77p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p4.png" medium="image">
			<media:title type="html">t77p4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p3.png" medium="image">
			<media:title type="html">t77p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p5.png" medium="image">
			<media:title type="html">t77p5</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p6.png" medium="image">
			<media:title type="html">t77p6</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t77p7.png" medium="image">
			<media:title type="html">t77p7</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p8.png" medium="image">
			<media:title type="html">t76p8</media:title>
		</media:content>
	</item>
		<item>
		<title>76. Working with PhotoShop brush effects in Silverlight</title>
		<link>http://silverlightips.net/2010/07/18/working-with-photoshop-brush-effects-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/07/18/working-with-photoshop-brush-effects-in-silverlight/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 09:37:27 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[photoshop silverlight]]></category>
		<category><![CDATA[silverlight import photoshop]]></category>
		<category><![CDATA[silverlight photoshop effects]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=828</guid>
		<description><![CDATA[In this entry, I will try to explain and show you, how to use Photoshop to your advantage in Silverlight. So starting from today’s entry, next couple of article will be devoted to this subject before I shift my focus to working with Microsoft lab tools in Silverlight. There are lots of free psd available on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=828&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://shamrat231.files.wordpress.com/2010/07/t76p1.png"><div class="tweetmeme-button" id="tweetmeme-button-post-828" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F18%2Fworking-with-photoshop-brush-effects-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-dm%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F18%2Fworking-with-photoshop-brush-effects-in-silverlight%2F" height="61" width="51" /></a>
</div><img class="alignnone size-full wp-image-829" title="t76p1" src="http://shamrat231.files.wordpress.com/2010/07/t76p1.png" alt="" width="362" height="473" /></a></p>
<p>In this entry, I will try to explain and show you, how to use Photoshop to your advantage in Silverlight. So starting from today’s entry, next couple of article will be devoted to this subject before I shift my focus to working with Microsoft lab tools in Silverlight. There are lots of free psd available on the internet. So I am going to import one that would be a good example in this scenario. I have taken the mirror picture from deviantart gallery for demonstration purpose.</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t76/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p>There are lots of free psd available on the internet. For this scenario, i am going to use some sample brush effects. The one I am going to use is <a href="http://www.officialpsds.com/Photoshop-Brushes-Broken-Glass-PSD9371.html">broken glass available here</a>.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t76p2.png"><img class="alignnone size-full wp-image-830" title="t76p2" src="http://shamrat231.files.wordpress.com/2010/07/t76p2.png" alt="" width="407" height="363" /></a>        <a href="http://shamrat231.files.wordpress.com/2010/07/t76p3.png"><img class="alignnone size-full wp-image-831" title="t76p3" src="http://shamrat231.files.wordpress.com/2010/07/t76p3.png" alt="" width="453" height="366" /></a></p>
<p>Ok, for now lets download the psd file and open it in Expression Blend 4. First start by creating a simple silverlight project. On the File menu, you will see that there are two options, since the download file is a psd file, I will choose the first choice. Once the file loaded, you will see on your user control section that some files are generated.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t76p4.png"><img class="alignnone size-full wp-image-832" title="t76p4" src="http://shamrat231.files.wordpress.com/2010/07/t76p4.png" alt="" width="273" height="84" /></a><a href="http://shamrat231.files.wordpress.com/2010/07/t76p5.png"><img class="alignnone size-full wp-image-833" title="t76p5" src="http://shamrat231.files.wordpress.com/2010/07/t76p5.png" alt="" width="684" height="297" /></a></p>
<p>These files depend on the number of layers available on Photoshop file. For this case, the total markup generated here is very small.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>&lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;White&#8221;&gt;<br />
 0L500,0 500,500 0,500z&#8221; HorizontalAlignment=&#8221;Left&#8221; Height=&#8221;500&#8243; UseLayoutRounding=&#8221;False&#8221; VerticalAlignment=&#8221;Top&#8221; Width=&#8221;500&#8243;&gt;<br />
  &lt;Image x:Name=&#8221;unique_psds&#8221; Height=&#8221;393&#8243; Canvas.Left=&#8221;0&#8243; Source=&#8221;Photoshop-Brushes-Broken-Glass-psd9371_Images/unique_psds.png&#8221; Canvas.Top=&#8221;31&#8243; Width=&#8221;500&#8243;/&gt;<br />
 &lt;/Canvas&gt;<br />
&lt;/Grid&gt;</p>
<p>So by seeing the markup, you might wonder that the generated output is an image instead of full xaml markup of the design. So lets check the generated output actually works or not. One simple test case would be to change the background color of the main grid or add an image for the background of the grid.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t76p6.png"><img class="alignnone size-full wp-image-834" title="t76p6" src="http://shamrat231.files.wordpress.com/2010/07/t76p6.png" alt="" width="330" height="281" /></a></p>
<p>So now modify the generated code to make it more flexible. For example, the background should stretch no matter what type of resolution the computer has.</p>
<p><span style="text-decoration:underline;"><strong>MainPage.xaml.cs</strong> </span>(modified)</p>
<p>&lt;UserControl<br />
 xmlns=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>&#8220;<br />
 xmlns:x=&#8221;<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>&#8220;<br />
 x:Class=&#8221;BrokenGlass.MainPage&#8221;<br />
 &gt;</p>
<p> &lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Black&#8221;&gt;<br />
  &lt;Image Source=&#8221;Mirror_by_audpod.jpg&#8221; Stretch=&#8221;Uniform&#8221; Margin=&#8221;50&#8243;/&gt;<br />
  &lt;Image x:Name=&#8221;unique_psds&#8221; Height=&#8221;220.5&#8243; Source=&#8221;Photoshop-Brushes-Broken-Glass-psd9371_Images/unique_psds.png&#8221; Width=&#8221;141.5&#8243; HorizontalAlignment=&#8221;Center&#8221; VerticalAlignment=&#8221;Center&#8221;/&gt;<br />
        &lt;HyperlinkButton Content=&#8221;Samples from <a href="http://silverlightips.net">http://silverlightips.net</a> by Sharker Khaleed Mahmud&#8221; NavigateUri=&#8221;<a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; IsTabStop=&#8221;False&#8221; Foreground=&#8221;White&#8221; HorizontalAlignment=&#8221;Center&#8221;/&gt;<br />
 &lt;/Grid&gt;<br />
&lt;/UserControl&gt;</p>
<p>So far, I have finished adding the effects in blend and applying it in front of an image. In the next entry, I will continue more with this sample and show how to create controls and other amazing stuffs.</p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=6HX10WGY" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">]</span> </p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t76p3.png"></a></p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/photoshop-silverlight/'>photoshop silverlight</a>, <a href='http://silverlightips.net/tag/silverlight-import-photoshop/'>silverlight import photoshop</a>, <a href='http://silverlightips.net/tag/silverlight-photoshop-effects/'>silverlight photoshop effects</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/828/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/828/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/828/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/828/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/828/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/828/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/828/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/828/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=828&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/07/18/working-with-photoshop-brush-effects-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p1.png" medium="image">
			<media:title type="html">t76p1</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p2.png" medium="image">
			<media:title type="html">t76p2</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p3.png" medium="image">
			<media:title type="html">t76p3</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p4.png" medium="image">
			<media:title type="html">t76p4</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p5.png" medium="image">
			<media:title type="html">t76p5</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t76p6.png" medium="image">
			<media:title type="html">t76p6</media:title>
		</media:content>
	</item>
		<item>
		<title>75. Visual Zooming Datalist using ListBox in Silverlight</title>
		<link>http://silverlightips.net/2010/07/10/visual-zooming-datalist-using-listbox-in-silverlight/</link>
		<comments>http://silverlightips.net/2010/07/10/visual-zooming-datalist-using-listbox-in-silverlight/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 10:14:07 +0000</pubDate>
		<dc:creator>Sharker Khaleed Mahmud &#124; shamrat231</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[silverlight blogs]]></category>
		<category><![CDATA[silverlight datalist]]></category>
		<category><![CDATA[wrap panel]]></category>
		<category><![CDATA[zooming collection]]></category>
		<category><![CDATA[zooming data]]></category>

		<guid isPermaLink="false">http://silverlightips.net/?p=762</guid>
		<description><![CDATA[In this entry, I am going to view a collection of data to represent like datalist using ListBox. Afterwards, add some simple interactive behaviours. In this case for the interactive zooming part, I will use Nikhilk&#8217;s Silverlight FX behaviours. You can just add your own sets of collection to this sample. This kind of representation seems to be very popular. Populated with images i found on search [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=762&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><div class="tweetmeme-button" id="tweetmeme-button-post-762" style='float: right; margin-left: 10px; margin-bottom: 5px; padding: 4px 0 2px 4px; background: #fff;'>
<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F10%2Fvisual-zooming-datalist-using-listbox-in-silverlight%2Ftweetmeme_alias%3Dhttp%3A%2F%2Fwp.me%2FpjEWm-ci%26tweetmeme_source%3D%E2%80%9Dshamrat231%E2%80%9D"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsilverlightips.net%2F2010%2F07%2F10%2Fvisual-zooming-datalist-using-listbox-in-silverlight%2F" height="61" width="51" /></a>
</div>In this entry, I am going to view a collection of data to <span style="text-decoration:underline;">represent like datalist using ListBox.</span> Afterwards, add some simple interactive behaviours. In this case for the interactive zooming part, I will use Nikhilk&#8217;s <a href="http://projects.nikhilk.net/SilverlightFX">Silverlight FX</a> behaviours. You can just add your own sets of collection to this sample. This kind of representation seems to be very popular. Populated with images i found on search engine.</p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t752.png"></a></p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t75_2.png"></a></p>
<p><a href="http://shamrat231.files.wordpress.com/2010/07/t75_21.png"><img class="alignnone size-full wp-image-825" title="t75_2" src="http://shamrat231.files.wordpress.com/2010/07/t75_21.png" alt="" width="834" height="439" /></a></p>
<p>If you want to add scrollviewer you have to add it like this.</p>
<p>&lt;ScrollViewer Width=&#8221;705&#8243; Height=&#8221;540&#8243; BorderThickness=&#8221;0&#8243;&gt;<br />
&lt;ListBox /&gt;<br />
&lt;/ScrollViewer&gt;</p>
<p>You can see the<strong> live example</strong> here <a title="[live demo]" href="http://usfromdhaka.com/shamrat231/t75/" target="_blank"><span style="color:#993300;">[live demo]</span></a></p>
<p>The <strong>SOURCE CODE(.zip) </strong>is at the end of the page for <strong>download</strong>.</p>
<p><span style="text-decoration:underline;">MainPage.xaml</span></p>
<p>&lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Gray&#8221; &gt;<br />
        &lt;Border x:Name=&#8221;ContentBorder&#8221; Width=&#8221;960&#8243; Height=&#8221;600&#8243; Background=&#8221;White&#8221; BorderThickness=&#8221;1&#8243; CornerRadius=&#8221;10&#8243; BorderBrush=&#8221;White&#8221;&gt;<br />
            &lt;ListBox x:Name=&#8221;LogoHost&#8221;  Style=&#8221;{StaticResource AutoWrap}&#8221;&gt;<br />
                &lt;ListBox.ItemTemplate&gt;<br />
                    &lt;DataTemplate&gt;<br />
                        &lt;Border HorizontalAlignment=&#8221;Center&#8221; VerticalAlignment=&#8221;Center&#8221;<br />
            BorderBrush=&#8221;White&#8221; BorderThickness=&#8221;4&#8243; CornerRadius=&#8221;0.5&#8243;<br />
            Cursor=&#8221;Hand&#8221;<br />
            RenderTransformOrigin=&#8221;0.5,0.5&#8243;&gt;<br />
                            &lt;Border.RenderTransform&gt;<br />
                                &lt;ScaleTransform /&gt;<br />
                            &lt;/Border.RenderTransform&gt;<br />
                            &lt;fxui:Interaction.Behaviors&gt;<br />
                                &lt;fxui:HoverEffect&gt;<br />
                                    &lt;fxeffects:Resize ScaleXRatio=&#8221;1.3&#8243; ScaleYRatio=&#8221;1.3&#8243; Duration=&#8221;0:0:.25&#8243; /&gt;<br />
                                fxui:HoverEffect&gt;<br />
                            fxui:Interaction.Behaviors&gt;<br />
                            &lt;Grid&gt;<br />
                                &lt;Image Source=&#8221;{Binding Logo}&#8221; Width=&#8221;85&#8243; Height=&#8221;85&#8243; /&gt;<br />
                            &lt;/Grid&gt;<br />
                        &lt;/Border&gt;<br />
                    &lt;/DataTemplate&gt;<br />
                &lt;/ListBox.ItemTemplate&gt;<br />
                &lt;ListBox.ItemsPanel&gt;<br />
                    &lt;ItemsPanelTemplate&gt;<br />
                        &lt;fxui:TilePanel TileHeight=&#8221;110&#8243; TileWidth=&#8221;110&#8243;<br />
            UseAnimatedLayout=&#8221;True&#8221; /&gt;<br />
                    &lt;/ItemsPanelTemplate&gt;<br />
                &lt;/ListBox.ItemsPanel&gt;<br />
            &lt;/ListBox&gt;<br />
        &lt;/Border&gt;<br />
        &lt;HyperlinkButton Content=&#8221;Samples from <a href="http://silverlightips.net">http://silverlightips.net</a> by Sharker Khaleed Mahmud&#8221; NavigateUri=&#8221;<a href="http://silverlightips.net">http://silverlightips.net</a>&#8221; Foreground=&#8221;White&#8221; VerticalAlignment=&#8221;Top&#8221; HorizontalAlignment=&#8221;Center&#8221; IsTabStop=&#8221;False&#8221;/&gt;<br />
    &lt;/Grid&gt;</p>
<p><span style="text-decoration:underline;">MainPage.xaml.cs</span></p>
<p>    //System.Windows.Control.Toolkit from Silverlight Toolkit<br />
    //Silverlight FX from Tips.Web\SilverlightFXDLL<br />
    public partial class MainPage : UserControl<br />
    {<br />
        public MainPage()<br />
        {<br />
            InitializeComponent();<br />
            this.LogoHost.ItemsSource = CompanyInfo.GetLogoSet();<br />
        }<br />
    }</p>
<p>As always, you can download the source code from here <span style="color:#993300;">[</span><a href="http://www.megaupload.com/?d=23NI8SMK" target="_blank"><span style="color:#993300;">download link</span></a><span style="color:#993300;">] </span></p>
<p>Sharker Khaleed Mahmud<br />
Web Developer</p>
<br />Filed under: <a href='http://silverlightips.net/category/silverlight/'>Silverlight</a> Tagged: <a href='http://silverlightips.net/tag/silverlight-blogs/'>silverlight blogs</a>, <a href='http://silverlightips.net/tag/silverlight-datalist/'>silverlight datalist</a>, <a href='http://silverlightips.net/tag/wrap-panel/'>wrap panel</a>, <a href='http://silverlightips.net/tag/zooming-collection/'>zooming collection</a>, <a href='http://silverlightips.net/tag/zooming-data/'>zooming data</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shamrat231.wordpress.com/762/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shamrat231.wordpress.com/762/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shamrat231.wordpress.com/762/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shamrat231.wordpress.com/762/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shamrat231.wordpress.com/762/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shamrat231.wordpress.com/762/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shamrat231.wordpress.com/762/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shamrat231.wordpress.com/762/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=silverlightips.net&amp;blog=4685610&amp;post=762&amp;subd=shamrat231&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://silverlightips.net/2010/07/10/visual-zooming-datalist-using-listbox-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/207815c5b723f2943b1c12154ed3b929?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shamrat231</media:title>
		</media:content>

		<media:content url="http://shamrat231.files.wordpress.com/2010/07/t75_21.png" medium="image">
			<media:title type="html">t75_2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
