tag:blogger.com,1999:blog-17837514562725797592024-02-18T22:04:16.169-08:00Advanced Dotnet TutorialDotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.comBlogger163125tag:blogger.com,1999:blog-1783751456272579759.post-74492789941397590312011-05-28T00:36:00.000-07:002011-05-28T00:37:32.298-07:00ASP.NET 4.0 Web Control ClientID<div dir="ltr" style="text-align: left;" trbidi="on"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"></span><br />
<div align="justify"><span style="font-family: Verdana; font-size: x-small;">In ASP.NET, each web control is identified uniquely using the ‘ID’ property of the control. We can access the server controls in the code behind using this ‘ID’ property. However, when the web form with server side controls renders in the form of HTML, the server side ID gets converted into client side ID. </span><br />
<a name='more'></a><br />
<span style="font-family: Verdana; font-size: x-small;"><br />
</span><br />
<span style="font-family: Verdana; font-size: x-small;">But for client-side developers, it becomes difficult when they want to access HTML elements using JavaScript. The reason is that the ‘ID’ property gets generated at runtime and is not known at design time. Although you can use expressions to access them, the code is not very readable.</span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;">In ASP.NET 4.0, Microsoft has given developers the control to render client side ID of server controls, by introducing a new property called ‘ClientIDMode’. It offers the following options to render the server side ‘ID’ at client end –</span></div><ol><li><div align="justify"><span style="font-family: Verdana; font-size: x-small;">AutoID – this is the same as previous web server control ‘ID’ rendering at client side.</span></div></li>
<li><div align="justify"><span style="font-family: Verdana; font-size: x-small;">Static – this option keeps the server ID name intact even at the client side. For example if the Textbox ID at server side is ‘txtCustomerID’ then at client side, it will remain as it is.</span></div></li>
<li><div align="justify"><span style="font-family: Verdana; font-size: x-small;">Predictable – this option is used for repeating templates like Gridview or Listview.</span></div></li>
<li><div align="justify"><span style="font-family: Verdana; font-size: x-small;">Inherit – ClientID will be generated the same way as Parent ID. For example, if the ParentID is ‘MainContent’ then the Textbox ‘txtCustomerID’ will be ‘MainContent_txtCustomerID’.</span></div></li>
</ol><div align="justify"><span style="font-family: Verdana; font-size: x-small;">Now let’s see some examples of the same. Create an ASP.NET 4.0 website with the name ‘ClientIDExample’ as shown below –</span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/asp.net-clientid-project.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/asp.net-clientid-project.png" width="320" /></a></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">Now let’s add the following pages to the application –</span></span></div><ul><li><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">InheritIDPage.aspx.</span></span></div></li>
<li><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">AutoIDPage.aspx.</span></span></div></li>
<li><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">StaticIDPage.aspx.</span></span></div></li>
<li><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">PredictableID.aspx.</span></span></div></li>
</ul><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">Make sure that you choose the ‘Site.master’ page when you add the above pages. Now let’s add code for the ‘AutoIDPage.aspx’ –</span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">Note: I have used document.writeln just for illustration purposes. It won’t work in a document that’s served as XHTML.</span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><img alt="asp.net-autoid-clientid" height="953" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/asp.net-autoid-clientid.png" style="border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; display: inline;" title="asp.net-autoid-clientid" width="593" /></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">In the above code, we are using JavaScript to print the client ID which is rendered from server side to client side.</span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">When you run this page, you will see an output similar to the one shown below –</span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/asp.net-autoid-clientid-output.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/asp.net-autoid-clientid-output.png" width="320" /></a></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"></span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">Now write the following code in our ‘StaticIDPage.aspx’ –</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><img alt="asp.net-staticid" height="913" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/asp.net-staticid.png" style="border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; display: inline;" title="asp.net-staticid" width="613" /></span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">Run this page and you should see the following output –</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image0014.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="211" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image0014.png" width="320" /></a></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">Now let’s add the following code in ‘InheritIDPage.aspx’ –</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/image.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="210" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/image.png" width="320" /></a></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/image_3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/image_3.png" width="320" /></a></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">In this demo, we are using the Northwind database and Employee table. In the ‘GridView’ control, we are setting two properties – ‘ClientIDMode’ and ‘ClientIDRowSuffix’. The ClientIDRowSuffix property is used during client ID generation. Now run this page. Right click the page in browser and view the source code. You will see the following output –</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image002.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="146" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image002.jpg" width="320" /></a></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">You can control the web control client ID generation at Page level as well as web site level. For eg: include ClientIDMode property at Page directive as shown below –</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div class="separator" style="clear: both; text-align: center;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image0016.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="77" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image0016.png" width="320" /></a></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;">If you want to set the ClientIDMode at web site level, you can use the web.config settings as shown below –</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div class="separator" style="clear: both; text-align: center;"><a href="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image002.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="71" src="http://www.dotnetcurry.com/images/sharepoint/63bc5717bab1_A0BF/clip_image002.png" width="320" /></a></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><br />
</span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"><span style="font-family: Verdana; font-size: x-small;">In this post, we have seen how easy it is to take control of Client ID generation as per our requirement. The entire <strong>source code</strong> of this article can be downloaded </span><strong style="color: #4292c6;"><span style="font-family: Verdana; font-size: x-small;"><a href="http://cid-2c5f5b0560e374cb.office.live.com/self.aspx/.Public/Uploads/ClientIDExample.zip" style="color: #4292c6;" target="_blank">over here</a></span></strong></span></span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"><strong style="color: #4292c6;"><br />
</strong></span></span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"><strong style="color: #4292c6;"><br />
</strong></span></span></span></span></div><div align="justify"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-family: Verdana; font-size: x-small;"><span class="Apple-style-span" style="font-family: Verdana, Calibri, Arial, serif; font-size: 12px;"><b>Read More :</b><strong style="color: #4292c6;"> </strong></span></span></span></span><a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=709">http://www.dotnetcurry.com/ShowArticle.aspx?ID=709</a></div><br />
<br />
</div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-47434214371822094582011-05-12T01:18:00.000-07:002011-05-13T13:29:57.687-07:00Tracing in .Net 2.0<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">Tracing is a new feature given in .Net 2.0 that helps the user to view different steps occurred while execution of a single ASP.net Page at run time. Tracing Information help you to investigate errors or unwanted results while ASP.Net process a page request.</span><br />
<a name='more'></a><br />
By default tracing is disabled so if you want to view the tracing information you have to enable the tracing.<br />
<br />
Tracing can be of two types Page Level Tracing and Application Level Tracing.<br />
<br />
<b>Page Level Tracing:</b><br />
<br />
Gives information about a particular page.<br />
<br />
To enable the page level tracing Add "Trace=true" in Page directive of ASP.Net Page<br />
<br />
<%@ Page Trace="true" %><br />
<br />
Other attribute that you can use here is TraceMode<br />
<br />
Set TraceMode to SortByTime to soert the Information in order in which they were processed.<br />
<br />
Set TraceMode to SortByCategory to sort the Information in the different categories<br />
<br />
<%@ Page Language="VB" Trace="True" TraceMode="SortByCategory" %><br />
<br />
<b>Application Level Tracing:<br />
</b>Gives information about whole application.<br />
<br />
Application level tracing can be enabled in web.config file by using the trace element inside system.web tag.<br />
<br />
<configuration><br />
<system.web><br />
<trace enabled="true" /><br />
</system.web><br />
</configuration><br />
<br />
Other elements that can be used are<br />
<br />
pageOutput-> Set this element to true if you want to display trace information at the end of page ;Set this element to false if you want to display trace information in TraceViewer.<br />
<br />
requestLimit-> Number that indicates for how many requests trace information is required.<br />
<br />
<b>Note: </b>Trace attribute in Page directive overwrites the trace attribute in web.config file.<br />
<br />
<b>How to view trace information with trace viewer<br />
</b>To do this tracing should be enabled in web.config file.<br />
<ol><li><span style="font-family: Verdana;">Navigate to trace.axd in the root of your application.<br />
<br />
For example, if the URL for your application is http://localhost/SampleApplication, navigate to http://localhost/SampleApplication/trace.axd to view the trace information for that application.<br />
</span> </li>
<li><span style="font-family: Verdana;">Select the View Details link for the request that you want to investigate. <br />
</span></li>
</ol><span style="font-family: Verdana;">READ MORE >></span><br />
<a href="http://www.c-sharpcorner.com/UploadFile/a954ae/7353/">http://www.c-sharpcorner.com/UploadFile/a954ae/7353/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-27396067375733637772011-05-11T04:21:00.000-07:002011-05-11T04:21:47.212-07:00CSS: Change Image of Button On Hover and Disabled<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">This article helps to understand how CSS is changed automatically when a button is disabled from the server side. Further, how to define CSS when a user hovers over an element.</span><br />
<a name='more'></a><br />
<b>Step 1: Define CSS for button</b><br />
<br />
Define two css (i.e. one for hover and another normal) for each button.<br />
<br />
<b>Button1: Which will enable 3rd button</b> <br />
<ol><li><span style="font-family: Verdana;">CSS for button1 when it is hovered by the user. Here CButtonMakeEnable:hover<br />
does it all; :hover defines what css is applied when an element is hovered.<br />
</span><span style="color: maroon; font-family: Verdana;">.CButtonMakeEnable:hover</span><span style="font-family: Verdana;"> {<br />
<span style="color: red;">background</span>: <span style="color: blue;">url("Images/buttonMakeEnableHover.png")</span>;<br />
<span style="color: red;">background-repeat</span>: <span style="color: blue;">no-repeat</span>;<br />
<span style="color: red;">background-position</span>: <span style="color: blue;">top</span> <span style="color: blue;">right</span>;<br />
<span style="color: red;">background-color</span>: <span style="color: blue;">transparent</span>;<br />
<span style="color: red;">cursor</span>: <span style="color: blue;">pointer</span>;<br />
<span style="color: red;">border</span>: <span style="color: blue;">0px</span>;<br />
<span style="color: red;">height</span>: <span style="color: blue;">48px</span>;<br />
<span style="color: red;">width</span>: <span style="color: blue;">48px</span>;<br />
}<br />
</span> </li>
<li><span style="font-family: Verdana;">CSS for button1 when it is not hovered by the user. Here the css is defined for normal behavior.<br />
</span><span style="font-family: Verdana;"> <span style="color: maroon;">.CButtonMakeEnable</span> {<br />
<span style="color: red;">background</span>: <span style="color: blue;">url("Images/buttonMakeEnableNormal.png")</span>;<br />
<span style="color: red;">background-repeat</span>: <span style="color: blue;">no-repeat</span>;<br />
<span style="color: red;">background-position</span>: <span style="color: blue;">top</span> <span style="color: blue;">right</span>;<br />
<span style="color: red;">background-color</span>: <span style="color: blue;">transparent</span>;<br />
<span style="color: red;">cursor</span>: <span style="color: blue;">pointer</span>;<br />
<span style="color: red;">border</span>: <span style="color: blue;">0px</span>;<br />
<span style="color: red;">height</span>: <span style="color: blue;">48px</span>;<br />
<span style="color: red;">width</span>: <span style="color: blue;">48px</span>;<br />
<span style="color: red;">outline-width</span>: <span style="color: blue;">0px</span>;<br />
}</span></li>
</ol><br />
<span style="font-family: Verdana;"><b>Button 2: Which will disable 3rd button</b></span> <br />
<ol><li><span style="font-family: Verdana;">CSS for button2 when it is hovered by user. Here .CButtonMakeDisable:hover does it all; :hover defines what css is applied when an element is hovered.<br />
</span><span style="color: maroon; font-family: Verdana;">.CButtonMakeDisable:hover</span><span style="font-family: Verdana;"> {<br />
<span style="color: red;">background</span>: <span style="color: blue;">url("Images/buttonMakeDisableHover.png")</span>;<br />
<span style="color: red;">background-repeat</span>: <span style="color: blue;">no-repeat</span>;<br />
<span style="color: red;">background-position</span>: <span style="color: blue;">top</span> <span style="color: blue;">right</span>;<br />
<span style="color: red;">background-color</span>: <span style="color: blue;">transparent</span>;<br />
<span style="color: red;">cursor</span>: <span style="color: blue;">pointer</span>;<br />
<span style="color: red;">border</span>: <span style="color: blue;">solid</span> <span style="color: blue;">0px</span> <span style="color: blue;">#ff0000</span>;<br />
<span style="color: red;">height</span>: <span style="color: blue;">48px</span>;<br />
<span style="color: red;">width</span>: <span style="color: blue;">48px</span>;<br />
}</span><span style="font-family: Verdana;"><br />
</span> </li>
<li><span style="font-family: Verdana;">CSS for button2 when it is not hovered by the user. Here the css is defined for the normal behavior.<br />
</span><span style="font-family: Verdana;"> <span style="color: maroon;">.CButtonMakeDisable</span> {<br />
<span style="color: red;">background</span>: <span style="color: blue;">url("Images/buttonMakeDisableNormal.png")</span>;<br />
<span style="color: red;">background-repeat</span>: <span style="color: blue;">no-repeat</span>;<br />
<span style="color: red;">background-position</span>: <span style="color: blue;">top</span> <span style="color: blue;">right</span>;<br />
<span style="color: red;">background-color</span>: <span style="color: blue;">transparent</span>;<br />
<span style="color: red;">cursor</span>: <span style="color: blue;">pointer</span>;<br />
<span style="color: red;">border</span>: <span style="color: blue;">solid</span> <span style="color: blue;">0px</span> <span style="color: blue;">#ff0000</span>;<br />
<span style="color: red;">height</span>: <span style="color: blue;">48px</span>;<br />
<span style="color: red;">width</span>: <span style="color: blue;">48px</span>;<br />
<span style="color: red;">outline-width</span>: <span style="color: blue;">0px</span>;<br />
}</span></li>
</ol><br />
<span style="font-family: Verdana;"><b>Button 3: Which will be enabled and disable by 1st and 2nd button.</b></span> <br />
<ol><li><span style="font-family: Verdana;">CSS for Enabled button3. This is defined for the normal behavior when the button is enabled.<br />
</span><span style="font-family: Verdana;"> <span style="color: maroon;">.CButton</span></span> <div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> {</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-image</span>: <span style="color: blue;">url("Images/bulbEnable.png")</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-repeat</span>: <span style="color: blue;">no-repeat</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-position</span>: <span style="color: blue;">top</span> <span style="color: blue;">right</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-color</span>: <span style="color: blue;">transparent</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">cursor</span>: <span style="color: blue;">pointer</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">border</span>: <span style="color: blue;">solid</span> <span style="color: blue;">0px</span> <span style="color: blue;">#ff0000</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">height</span>: <span style="color: blue;">48px</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">width</span>: <span style="color: blue;">48px</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">outline-width</span>: <span style="color: blue;">0px</span>;<br />
}</span><span style="font-family: Verdana;"><br />
</span> </div></li>
<li><span style="font-family: Verdana;">CSS for disabled button3, when the button is disabled. Here .CButton[disabled] does it all; this ccs is automatically applied when the element is disabled.<br />
</span> <div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: maroon;">.CButton[disabled]</span></span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> {</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background</span>: <span style="color: blue;">url("Images/bulbDisable.png")</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-repeat</span>: <span style="color: blue;">no-repeat</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-position</span>: <span style="color: blue;">top</span> <span style="color: blue;">right</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">background-color</span>: <span style="color: blue;">transparent</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">cursor</span>: <span style="color: blue;">pointer</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">border</span>: <span style="color: blue;">solid</span> <span style="color: blue;">0px</span> <span style="color: blue;">#ff0000</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">height</span>: <span style="color: blue;">48px</span>;</span> </div><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.5in;"><span style="font-family: Verdana;"> <span style="color: red;">width</span>: <span style="color: blue;">48px</span>;<br />
}</span> </div></li>
</ol><br />
<span style="font-family: Verdana;"><b>All buttons in Normal/Enabled state<br />
</b><img alt="CSS1.gif" border="0" height="190px" src="http://www.c-sharpcorner.com/UploadFile/e1317f/7220/Images/CSS1.gif" width="121px" /><br />
<br />
READ MORE >></span><br />
<a href="http://www.c-sharpcorner.com/UploadFile/e1317f/7220/">http://www.c-sharpcorner.com/UploadFile/e1317f/7220/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-13489679085383991872011-05-09T21:35:00.000-07:002011-05-09T21:35:29.136-07:00Tweeter search application with Silverlight (Beginners) your first Silverlight application<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">Developers who are new to Silverlight or in learning phase this demo/article can help them creating a small application. This isn't just a hello world application this something interesting more than that. So ready to get your hand dirty with some XAML code and little bit power of Silverlight.</span><br />
<a name='more'></a><br />
To create a Silverlight project you should have Silverlight library component installed on your computer. If you have visual studio 2010 installed then you are good to go as Silverlight 3.0 project template can be found there. <br />
<ol><li><span style="font-family: Verdana;">Open a new project -> and select the Silverlight application from the Silverlight template.<br />
<br />
<img alt="Silverlight1.gif" border="0" height="245px" src="http://www.c-sharpcorner.com/UploadFile/vendettamit/7294/Images/Silverlight1.gif" width="624px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Now when you click OK you'll see the next window prompting you few more details about what kinda project you want to run your Silverlight application with in:<br />
<br />
<img alt="Silverlight2.gif" border="0" height="414px" src="http://www.c-sharpcorner.com/UploadFile/vendettamit/7294/Images/Silverlight2.gif" width="518px" /></span></li>
</ol><div style="text-align: left;"><span style="font-family: Verdana;">Leave the default selections and click OK.<br />
<br />
Now you'll see two projects in your solution explorer.<br />
<br />
<img alt="Silverlight3.gif" border="0" height="295px" src="http://www.c-sharpcorner.com/UploadFile/vendettamit/7294/Images/Silverlight3.gif" width="291px" /><br />
<br />
Let go to our MainPage.xaml file to create some UI for our application. Add a Button and Listbox will create a UI and XAML like this. Set the Name and Content properties for your convenience.<br />
<br />
<img alt="Silverlight4.gif" border="0" height="302px" src="http://www.c-sharpcorner.com/UploadFile/vendettamit/7294/Images/Silverlight4.gif" width="403px" /><br />
</span><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">UserControl</span><span style="color: red; font-family: Verdana;"> x</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">Class</span><span style="color: blue; font-family: Verdana;">="TweeterSilverlightSearch.MainPage"</span><span style="color: red; font-family: Verdana;"> xmlns</span><span style="color: blue; font-family: Verdana;">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span><span style="color: red; font-family: Verdana;"> xmlns</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">x</span><span style="color: blue; font-family: Verdana;">="http://schemas.microsoft.com/winfx/2006/xaml"</span><span style="color: red; font-family: Verdana;"> xmlns</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">d</span><span style="color: blue; font-family: Verdana;">="http://schemas.microsoft.com/expression/blend/2008"</span><span style="color: red; font-family: Verdana;"> xmlns</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">mc</span><span style="color: blue; font-family: Verdana;">="http://schemas.openxmlformats.org/markup-compatibility/2006"</span><span style="color: red; font-family: Verdana;"> mc</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">Ignorable</span><span style="color: blue; font-family: Verdana;">="d"</span><span style="color: red; font-family: Verdana;"> d</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">DesignHeight</span><span style="color: blue; font-family: Verdana;">="300"</span><span style="color: red; font-family: Verdana;"> d</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">DesignWidth</span><span style="color: blue; font-family: Verdana;">="400"></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">Grid</span><span style="color: red; font-family: Verdana;"> x</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: red; font-family: Verdana;">Name</span><span style="color: blue; font-family: Verdana;">="LayoutRoot"</span><span style="color: red; font-family: Verdana;"> Background</span><span style="color: blue; font-family: Verdana;">="White"><br />
<</span><span style="color: #a31515; font-family: Verdana;">Button</span><span style="color: red; font-family: Verdana;"> Content</span><span style="color: blue; font-family: Verdana;">="Get Tweets"</span><span style="color: red; font-family: Verdana;"> Height</span><span style="color: blue; font-family: Verdana;">="23"</span><span style="color: red; font-family: Verdana;"> HorizontalAlignment</span><span style="color: blue; font-family: Verdana;">="Left"</span><span style="color: red; font-family: Verdana;"> Margin</span><span style="color: blue; font-family: Verdana;">="12,12,0,0"</span><span style="color: red; font-family: Verdana;"> Name</span><span style="color: blue; font-family: Verdana;">="btn_GetTweets"</span><span style="color: red; font-family: Verdana;"> VerticalAlignment</span><span style="color: blue; font-family: Verdana;">="Top"</span><span style="color: red; font-family: Verdana;"> Width</span><span style="color: blue; font-family: Verdana;">="75"</span><span style="color: red; font-family: Verdana;"> Click</span><span style="color: blue; font-family: Verdana;">="btn_GetTweets_Click" /><br />
<</span><span style="color: #a31515; font-family: Verdana;">ListBox</span><span style="color: red; font-family: Verdana;"> Height</span><span style="color: blue; font-family: Verdana;">="247"</span><span style="color: red; font-family: Verdana;"> HorizontalAlignment</span><span style="color: blue; font-family: Verdana;">="Left"</span><span style="color: red; font-family: Verdana;"> Margin</span><span style="color: blue; font-family: Verdana;">="12,41,0,0"</span><span style="color: red; font-family: Verdana;"> Name</span><span style="color: blue; font-family: Verdana;">="TweetList"</span><span style="color: red; font-family: Verdana;"> VerticalAlignment</span><span style="color: blue; font-family: Verdana;">="Top"</span><span style="color: red; font-family: Verdana;"> Width</span><span style="color: blue; font-family: Verdana;">="376" /><br />
</</span><span style="color: #a31515; font-family: Verdana;">Grid</span><span style="color: blue; font-family: Verdana;">><br />
</</span><span style="color: #a31515; font-family: Verdana;">UserControl</span><span style="color: blue; font-family: Verdana;">></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="font-family: Verdana;"> </span><span style="font-family: Verdana;">This mark up is your MainPage.xaml file. Now let write something in button click event of GetTweets button. </span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="color: blue; font-family: Verdana;">private void</span><span style="font-family: Verdana;"> btn_GetTweets_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RoutedEventArgs</span> e)<br />
{</span><span style="color: #2b91af; font-family: Verdana;">WebClient</span><span style="font-family: Verdana;"> client = <span style="color: blue;">new</span><span style="color: #2b91af;">WebClient</span>();</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="color: green; font-family: Verdana;">//This event will let us know about the downloading competion<br />
/*Experts prefer not to create seperate event handler for one time event handling they <br />
* prefer to have Anonymous handler using delegates and lambda expressions.<br />
* for e.g. <br />
* client.DownloadStringCompleted += (s, ea) => { System.Diagnostics.Debug.WriteLine(ea.Result); };<br />
* <br />
* no need to write a seperate lines for writing handler code and it'll reduce the lines of code and increase<br />
* the code beauty as you can see.<br />
* */</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="font-family: Verdana;"> client.DownloadStringCompleted += <span style="color: blue;">new</span><span style="color: #2b91af;">DownloadStringCompletedEventHandler</span>(client_DownloadStringCompleted);</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="color: green; font-family: Verdana;">//Let's do our main job</span><span style="font-family: Verdana;"> client.DownloadStringAsync(<span style="color: blue;">new</span><span style="color: #2b91af;">Uri</span>(<span style="color: #a31515;">"http://search.twitter.com/search.atom?q=silverlight"</span>));<br />
}</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt; text-align: left;"><span style="color: blue; font-family: Verdana;">void</span><span style="font-family: Verdana;"> client_DownloadStringCompleted(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">DownloadStringCompletedEventArgs</span> e)<br />
{<br />
System.Diagnostics.<span style="color: #2b91af;">Debug</span>.WriteLine(e.Result);<br />
}<br />
<br />
READ MORE >></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"><a href="http://www.c-sharpcorner.com/UploadFile/vendettamit/7294/">http://www.c-sharpcorner.com/UploadFile/vendettamit/7294/</a></span></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-61107367488947711762011-05-08T23:43:00.000-07:002011-05-08T23:43:45.176-07:00Editing the Path of any Shape in XAML Silverlight<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">In Expressing Blend we are not only limited to draw some primitives line rectangle, line or ellipse. Expression Blend help us to create any shape. Expression Blen has two tools named Pen and Pencil which let us to create path and selection cursor let us to modify the shape. Let's create any shape using these tools.</span></div><a name='more'></a><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">Follow the steps:</span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><b><span style="font-family: Verdana,sans-serif; line-height: 14px;">Step 1</span></b></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">Create a new project in Expression Blend and draw a rectangle and fill any color.</span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><b><span style="font-family: Verdana,sans-serif; line-height: 14px;">Step 2</span></b></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">Using selection tool select the rectangle and click on Object > Path > Convert to Path. This option will add four anchor points to rectangle, click on 'Direct Selection' tool to view that anchors.</span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><b><span style="font-family: Verdana,sans-serif; line-height: 14px;">Step 3</span></b></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">Now select Pen tool to add three new anchor points in exiting rectangle shape. Notice, you click to add new anchor when see + sign with pen tool and also notice the – sign with pen tool to delete exiting anchor point. Press Ctrl+Z for undo.</span></div><div class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 14px;"><img alt="image002.jpg" border="0" height="238px" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7268/Images/image002.jpg" width="206px" /></span></span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><b><span style="font-family: Verdana,sans-serif; line-height: 14px;">Step 4</span></b></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">After inserting two new anchor points select the 'Direct Selection' tool and modify the shape by dragging center anchors.</span></div><div class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 14px;"><img alt="image004.jpg" border="0" height="302px" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7268/Images/image004.jpg" width="270px" /></span></span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><b><span style="font-family: Verdana,sans-serif; line-height: 14px;">Step 5</span></b></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">Now fill some Radial Gradient color to shape to create shape as</span></div><div class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;"><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><span class="Apple-style-span" style="line-height: 14px;"><img alt="image006.jpg" border="0" height="297px" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7268/Images/image006.jpg" width="256px" /></span></span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><b><span style="font-family: Verdana,sans-serif; line-height: 14px;">Step 6</span></b></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">Now select the 'Direct Selection' tool and select three anchor points by pressing Ctrl key and move it downward.</span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><br />
</div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;">READ MORE>></span></div><div class="MsoNormal" style="font-family: Calibri,sans-serif; line-height: 17px; margin: 0in 0in 10pt; text-align: justify;"><span style="font-family: Verdana,sans-serif; line-height: 14px;"><a href="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7268/">http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7268/</a></span></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-41067304136657112622011-05-05T21:45:00.000-07:002011-05-05T21:45:02.753-07:00Add a polygon to the Silverlight Bing Map<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;"><strong>MapPolygon:</strong>The MapPolygon class accepts a list of points that define its shape and location on the map.<br />
<br />
MapPolygon class is used to represent a polygon on the map.</span><br />
<a name='more'></a><br />
<br />
<b>Namespace:</b> Microsoft.Maps.MapControl<br />
<br />
<b>Assembly:</b> Microsoft.Maps.MapControl (in microsoft.maps.mapcontrol.dll) <br />
<br />
<b>Create Silverlight application:</b><br />
<ul><li><span style="font-family: Verdana;">Open Visual Studio 2010. </span></li>
<li><span style="font-family: Verdana;">Go to File => New => Project. </span></li>
<li><span style="font-family: Verdana;">Select Silverlight Application from the installed templates Silverlight.<br />
<br />
<img alt="BingSilver1.gif" border="0" height="385px" src="http://www.c-sharpcorner.com/UploadFile/anavijai/7133/Images/BingSilver1.gif" width="631px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Enter the Name and click on Ok. </span></li>
<li><span style="font-family: Verdana;">Click OK. </span></li>
<li><span style="font-family: Verdana;">Go to C:\Program Files (x86)\Bing Maps Silverlight Control\V1\Libraries\ (Check the path where you have installed Bing Maps Silverlight Control). </span></li>
<li><span style="font-family: Verdana;">Add the following assemblies to the project.<br />
<br />
o Microsoft.Maps.MapControl.Common.dll<br />
o Microsoft.Maps.MapControl.dll<br />
</span> </li>
<li><div style="text-align: left;"><span style="font-family: Verdana;">Replace MainPage.xaml with the following code</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">UserControl</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> x</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">:</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;">Class</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="SilverlightMapControl.MainPage"</span><span style="font-family: Verdana,sans-serif; line-height: 115%;"> <span style="color: red;"> xmlns</span><span style="color: blue;">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span> <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">="http://schemas.microsoft.com/winfx/2006/xaml"</span> <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">d</span><span style="color: blue;">="http://schemas.microsoft.com/expression/blend/2008"</span> <span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">mc</span><span style="color: blue;">="http://schemas.openxmlformats.org/markup-compatibility/2006"</span> <span style="color: red;"> <span style="background: yellow;">xmlns</span></span><span style="background: yellow; color: blue;">:</span><span style="background: yellow; color: red;">map</span><span style="background: yellow; color: blue;">="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"</span> <span style="color: red;"> mc</span><span style="color: blue;">:</span><span style="color: red;">Ignorable</span><span style="color: blue;">="d"</span> <span style="color: red;"> d</span><span style="color: blue;">:</span><span style="color: red;">DesignHeight</span><span style="color: blue;">="300"</span><span style="color: red;"> d</span><span style="color: blue;">:</span><span style="color: red;">DesignWidth</span><span style="color: blue;">="400"></span><span style="color: #a31515;"> </span></span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Grid</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> x</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">:</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;">Name</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="LayoutRoot"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Background</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="White"></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> <br />
</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Grid.RowDefinitions</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> </span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">RowDefinition</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Height</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="35" /></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> </span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">RowDefinition</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Height</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="*" /></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> </span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"></</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Grid.RowDefinitions</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> </span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Button</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> x</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">:</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;">Name</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="btnCreatePolygon"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Width</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="100"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Height</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="25"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Content</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="Create Polygon"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> HorizontalAlignment</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="Left"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Tag</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="false"</span><span style="font-family: Verdana,sans-serif; line-height: 115%;"> <span style="color: red;"> Click</span><span style="color: blue;">="btnCreatePolygon_Click"></</span><span style="color: #a31515;">Button</span><span style="color: blue;">></span></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> </span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">map</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">:</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Map</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> x</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">:</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;">Name</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="MapWithPolygon"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> CredentialsProvider</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="your key"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Mode</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="Road"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Grid.Row</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="1"</span><span style="color: red; font-family: Verdana,sans-serif; line-height: 115%;"> Grid.ColumnSpan</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">="2"></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> </span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"></</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">map</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">:</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Map</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">></span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;"> <br />
</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;"></</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">Grid</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">><br />
</</span><span style="color: #a31515; font-family: Verdana,sans-serif; line-height: 115%;">UserControl</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">></span><span style="font-family: Verdana;"><br />
</span> </div></li>
<li><div style="text-align: left;"><span style="font-family: Verdana;">Add the following in MainPage.xaml.cs.</span><span style="color: blue; font-family: Verdana,sans-serif; line-height: 115%;">private</span><span style="font-family: Verdana,sans-serif; line-height: 115%;"> <span style="color: blue;">void</span> btnCreatePolygon_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RoutedEventArgs</span> e)<br />
{ <br />
<span style="color: #2b91af;">MapPolygon</span> polygon = <span style="color: blue;">new</span> <span style="color: #2b91af;">MapPolygon</span>();<br />
polygon.Fill = <span style="color: blue;">new</span> System.Windows.Media.<span style="color: #2b91af;">SolidColorBrush</span>(System.Windows.Media.<span style="color: #2b91af;">Colors</span>.Gray);<br />
polygon.Stroke = <span style="color: blue;">new</span> System.Windows.Media.<span style="color: #2b91af;">SolidColorBrush</span>(System.Windows.Media.<span style="color: #2b91af;">Colors</span>.Black);<br />
polygon.StrokeThickness = 1;<br />
polygon.Opacity = 0.7;<br />
polygon.Locations = <span style="color: blue;">new</span> <span style="color: #2b91af;">LocationCollection</span>() { <br />
<span style="color: blue;">new</span> <span style="color: #2b91af;">Location</span>(15,-15),<br />
<span style="color: blue;">new</span> <span style="color: #2b91af;">Location</span>(15,15),<br />
<span style="color: blue;">new</span> <span style="color: #2b91af;">Location</span>(-15,15),<br />
<span style="color: blue;">new</span> <span style="color: #2b91af;">Location</span>(-15,-15)};<br />
MapWithPolygon.Children.Add(polygon);<br />
}</span><span style="font-family: Verdana;"><br />
</span> </div></li>
<li><span style="font-family: Verdana;">Build the solution.</span> </li>
<li><span style="font-family: Verdana;">Hit F5.</span> </li>
<li><span style="font-family: Verdana;">The output looks like the following</span></li>
</ul><span style="font-family: Verdana;">READ MORE >></span><br />
<a href="http://www.c-sharpcorner.com/UploadFile/anavijai/7133/">http://www.c-sharpcorner.com/UploadFile/anavijai/7133/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-239256265443402392011-05-04T23:30:00.000-07:002011-05-04T23:30:57.627-07:00Getting started with testing an ASP.NET Webforms Application (MVP Pattern)<div dir="ltr" style="text-align: left;" trbidi="on"><span id="ctl00_ArticleInfo1_desc">In this article we explore how unit tests are created in an ASP.NET WebForms Application. Although there are sections that are specific to the MVP pattern, there are also a few tips and guidelines about Unit Testing of a Web Application in general.</span><br />
<a name='more'></a><br />
<span>The purpose of this article is to explain how to test an ASP.NET Webforms Applications. How the Model-View-Presenter pattern is helping us in that, how do we use mock-up libraries to simulate objects like HttpContext and how do we use Visual Studio 2010 Testing Environment.<br />
<a href="" name="s2-testing-web-applications"></a><h3><span style="font-size: small;">Testing Web Applications </span></h3>First of all, when we want to test a Web Application we are considering two types of tests. Acceptance Tests and Unit Tests.<br />
<a href="" name="s3-acceptance-tests"></a><h4>Acceptance Tests </h4>Acceptance Tests are tests from a user prospective and most of the times an automated-browser testing tool is used (like WatiN, Selenium etc.) So we are testing the user experience, if our app works in different browsers, if client-validation works as it should etc.<br />
<a href="" name="s4-unit-tests"></a><h4>Unit Tests </h4>Unit Tests are tests dedicated to test our code, our business logic and validation, our database interaction and everything that are not related to how data is displayed. Although many times Unit Tests and Acceptance Test may have overlapping areas (example, when testing if a page works simultaneously validation is also being tested) it's important to have both in a project.<br />
For now, let's focus on Unit Tests.<br />
<a href="" name="s5-example"></a><h3><span style="font-size: small;">Example </span></h3>Let's consider the following real world but simple example:<br />
Almost every website has a contact page. The user enters his details and sends them to the server. The server processes the data and informs the user about the result. How can we test a page like this?<br />
<h4>Figure 1: Screenshot - Contact Page </h4><img alt="Screenshot - Contact Page" height="554px" src="http://dotnetslackers.com/images/articleimages/getting-started-with-testing-in-aspnet-webforms-1.jpg" title="Screenshot - Contact Page" width="546px" /><br />
<a href="" name="s6-explaining-the-mvp-pattern"></a><h3><span style="font-size: small;">Explaining the MVP Pattern </span></h3>The MVP pattern stands for Model-View-Presenter and doesn't differ a lot from MVC (Model-View-Controller). When an application is developed using the MVP pattern it's more testable because layers are being separated from each other. So each layer's responsibility is clearer thus easier to define test cases to run against. An excellent open-source framework that helps us build a WebForms application using the MVP Pattern is <a href="http://webformsmvp.com/" rel="nofollow">WebFormsMVP</a>. This framework is being used in this example.<br />
An implementation of the page above using the MVP Pattern along with a brief explanation of the pattern its self would be the following.<br />
<a href="" name="s7-model"></a><h4>Model </h4>Model is the class that holds the data of our page. In this case it is a simple class with three properties that are represented by our text fields and one property that holds if the Model is persisted or not to our database.<br />
<h4>Listing 1: ContactModel.cs </h4><div class="syntaxhighlighter " id="highlighter_467924"><div class="bar "><div class="toolbar"><a class="item viewSource" commandname="viewSource" highlighterid="highlighter_467924" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#viewSource" style="height: 16px; width: 16px;" title="view source">view source</a><a class="item printSource" commandname="printSource" highlighterid="highlighter_467924" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#printSource" style="height: 16px; width: 16px;" title="print">print</a><a class="item about" commandname="about" highlighterid="highlighter_467924" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#about" style="height: 16px; width: 16px;" title="?">?</a></div></div><div class="lines"><div class="line alt1"><code class="number">1.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="keyword">public</code> <code class="keyword">class</code> <code class="plain">ContactModel </code></span></span></div><div class="line alt2"><code class="number">2.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">{ </code></span></span></div><div class="line alt1"><code class="number">3.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">string</code> <code class="plain">Name { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt2"><code class="number">4.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">string</code> <code class="plain">Message { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt1"><code class="number">5.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="plain">enProcessState ProcessState { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt2"><code class="number">6.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">string</code> <code class="plain">Email { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt1"><code class="number">7.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">}</code></span></span></div></div></div>It's also included just for reference the enProcessState enum.<br />
<h4>Listing 2: enProcessState.cs </h4><div class="syntaxhighlighter " id="highlighter_497791"><div class="bar "><div class="toolbar"><a class="item viewSource" commandname="viewSource" highlighterid="highlighter_497791" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#viewSource" style="height: 16px; width: 16px;" title="view source">view source</a><a class="item printSource" commandname="printSource" highlighterid="highlighter_497791" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#printSource" style="height: 16px; width: 16px;" title="print">print</a><a class="item about" commandname="about" highlighterid="highlighter_497791" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#about" style="height: 16px; width: 16px;" title="?">?</a></div></div><div class="lines"><div class="line alt1"><code class="number">1.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="keyword">public</code> <code class="keyword">enum</code> <code class="plain">enProcessState </code></span></span></div><div class="line alt2"><code class="number">2.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">{ </code></span></span></div><div class="line alt1"><code class="number">3.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain">Pending, </code></span></span></div><div class="line alt2"><code class="number">4.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain">Saved </code></span></span></div><div class="line alt1"><code class="number">5.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">}</code></span></span></div></div></div><a href="" name="s8-view"></a><h4>View </h4>View, in this case, is the user control that displays the form and defines events – if necessary – that correspond to user actions. Because a view can be implemented in various ways an <b>interface </b>is being defined and the user <b>control is implementing </b>that interface.<br />
<h4>Listing 3: IContactView.cs </h4><div class="syntaxhighlighter " id="highlighter_326412"><div class="bar "><div class="toolbar"><a class="item viewSource" commandname="viewSource" highlighterid="highlighter_326412" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#viewSource" style="height: 16px; width: 16px;" title="view source">view source</a><a class="item printSource" commandname="printSource" highlighterid="highlighter_326412" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#printSource" style="height: 16px; width: 16px;" title="print">print</a><a class="item about" commandname="about" highlighterid="highlighter_326412" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#about" style="height: 16px; width: 16px;" title="?">?</a></div></div><div class="lines"><div class="line alt1"><code class="number">01.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="keyword">public</code> <code class="keyword">interface</code> <code class="plain">IContactView : IView<ContactModel> </code></span></span></div><div class="line alt2"><code class="number">02.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">{ </code></span></span></div><div class="line alt1"><code class="number">03.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">event</code> <code class="plain">EventHandler<ContactEventArgs> Contacting; </code></span></span></div><div class="line alt2"><code class="number">04.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">} </code></span></span></div><div class="line alt1"><code class="number">05.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="keyword">public</code> <code class="keyword">class</code> <code class="plain">ContactEventArgs : EventArgs </code></span></span></div><div class="line alt2"><code class="number">06.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">{ </code></span></span></div><div class="line alt1"><code class="number">07.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">string</code> <code class="plain">Name { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt2"><code class="number">08.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">string</code> <code class="plain">Email { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt1"><code class="number">09.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">string</code> <code class="plain">Message { </code><code class="keyword">get</code><code class="plain">; </code><code class="keyword">set</code><code class="plain">; } </code></span></span></div><div class="line alt2"><code class="number">10.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">}</code></span></span></div></div></div>The implementation of the interface is our user control.<br />
<h4>Listing 4: ContactControl.ascx </h4><div class="syntaxhighlighter " id="highlighter_23534"><div class="bar "><div class="toolbar"><a class="item viewSource" commandname="viewSource" highlighterid="highlighter_23534" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#viewSource" style="height: 16px; width: 16px;" title="view source">view source</a><a class="item printSource" commandname="printSource" highlighterid="highlighter_23534" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#printSource" style="height: 16px; width: 16px;" title="print">print</a><a class="item about" commandname="about" highlighterid="highlighter_23534" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#about" style="height: 16px; width: 16px;" title="?">?</a></div></div><div class="lines"><div class="line alt1"><code class="number">01.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain"><</code><code class="keyword">asp:MultiView</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">ID</code><code class="plain">=</code><code class="string">"mv"</code> <code class="color1">ActiveViewIndex</code><code class="plain">=</code><code class="string">"0"</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">02.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain"><</code><code class="keyword">asp:View</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">ID</code><code class="plain">=</code><code class="string">"vContact"</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">03.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain"><</code><code class="keyword">fieldset</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">04.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 84px! important;"><code class="plain"><</code><code class="keyword">legend</code><code class="plain">>Contact Us</</code><code class="keyword">legend</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">05.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 84px! important;"><code class="plain"><</code><code class="keyword">table</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">06.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"><</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">07.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">08.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain">Name </code></span></span></div><div class="line alt1"><code class="number">09.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">10.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">11.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain"><</code><code class="keyword">asp:TextBox</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">ID</code><code class="plain">=</code><code class="string">"txtName"</code> <code class="plain">/> </code></span></span></div><div class="line alt2"><code class="number">12.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain"><</code><code class="keyword">asp:RequiredFieldValidator</code> <code class="color1">ErrorMessage</code><code class="plain">=</code><code class="string">"*"</code> <code class="color1">ControlToValidate</code><code class="plain">=</code><code class="string">"txtName"</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="plain">/> </code></span></span></div><div class="line alt1"><code class="number">13.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">14.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"></</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">15.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"><</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">16.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">17.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain">Email </code></span></span></div><div class="line alt2"><code class="number">18.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">19.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">20.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain"><</code><code class="keyword">asp:TextBox</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">ID</code><code class="plain">=</code><code class="string">"txtEmail"</code> <code class="plain">/> </code></span></span></div><div class="line alt1"><code class="number">21.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">22.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"></</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">23.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"><</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">24.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">25.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain">Message </code></span></span></div><div class="line alt2"><code class="number">26.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">27.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">28.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain"><</code><code class="keyword">asp:TextBox</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">ID</code><code class="plain">=</code><code class="string">"txtMessage"</code> <code class="color1">TextMode</code><code class="plain">=</code><code class="string">"MultiLine"</code> <code class="color1">Rows</code><code class="plain">=</code><code class="string">"10"</code> <code class="plain">/> </code></span></span></div><div class="line alt1"><code class="number">29.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">30.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"></</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">31.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"><</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">32.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"><</code><code class="keyword">td</code> <code class="color1">colspan</code><code class="plain">=</code><code class="string">"2"</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">33.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 168px! important;"><code class="plain"><</code><code class="keyword">asp:Button</code> <code class="color1">Text</code><code class="plain">=</code><code class="string">"Contact Us"</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">OnClick</code><code class="plain">=</code><code class="string">"btnContactUs_Click"</code> <code class="plain">/> </code></span></span></div><div class="line alt2"><code class="number">34.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 140px! important;"><code class="plain"></</code><code class="keyword">td</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">35.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 112px! important;"><code class="plain"></</code><code class="keyword">tr</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">36.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 84px! important;"><code class="plain"></</code><code class="keyword">table</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">37.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain"></</code><code class="keyword">fieldset</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">38.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain"></</code><code class="keyword">asp:View</code><code class="plain">> </code></span></span></div><div class="line alt1"><code class="number">39.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain"><</code><code class="keyword">asp:View</code> <code class="color1">runat</code><code class="plain">=</code><code class="string">"server"</code> <code class="color1">ID</code><code class="plain">=</code><code class="string">"vSaved"</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">40.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">Contact request was Saved! <</code><code class="keyword">a</code> <code class="color1">href</code><code class="plain">=</code><code class="string">"ContactList.aspx"</code><code class="plain">>View all</</code><code class="keyword">a</code><code class="plain">> contact requests. </code></span></span></div><div class="line alt1"><code class="number">41.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain"></</code><code class="keyword">asp:View</code><code class="plain">> </code></span></span></div><div class="line alt2"><code class="number">42.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain"></</code><code class="keyword">asp:MultiView</code><code class="plain">></code></span></span></div></div></div>And our code-behind is the following.<br />
<h4>Listing 5: ContactControl.ascx.cs </h4><div class="syntaxhighlighter " id="highlighter_174797"><div class="bar show"><div class="toolbar"><a class="item viewSource" commandname="viewSource" highlighterid="highlighter_174797" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#viewSource" style="height: 16px; width: 16px;" title="view source">view source</a><a class="item printSource" commandname="printSource" highlighterid="highlighter_174797" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#printSource" style="height: 16px; width: 16px;" title="print">print</a><a class="item about" commandname="about" highlighterid="highlighter_174797" href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx#about" style="height: 16px; width: 16px;" title="?">?</a></div></div><div class="lines"><div class="line alt1"><code class="number">01.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="keyword">public</code> <code class="plain">partial </code><code class="keyword">class</code> <code class="plain">ContactControl : MvpUserControl<ContactModel>, IContactView </code></span></span></div><div class="line alt2"><code class="number">02.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">{ </code></span></span></div><div class="line alt1"><code class="number">03.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">public</code> <code class="keyword">event</code> <code class="plain">EventHandler<ContactEventArgs> Contacting; </code></span></span></div><div class="line alt2"><code class="number">04.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">private</code> <code class="keyword">void</code> <code class="plain">OnContacting(ContactEventArgs args) </code></span></span></div><div class="line alt1"><code class="number">05.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain">{ </code></span></span></div><div class="line alt2"><code class="number">06.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="keyword">if</code> <code class="plain">(Contacting != </code><code class="keyword">null</code><code class="plain">) </code></span></span></div><div class="line alt1"><code class="number">07.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 84px! important;"><code class="plain">Contacting(</code><code class="keyword">this</code><code class="plain">, args); </code></span></span></div><div class="line alt2"><code class="number">08.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain">} </code></span></span></div><div class="line alt1"><code class="number">09.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="keyword">protected</code> <code class="keyword">void</code> <code class="plain">btnContactUs_Click(</code><code class="keyword">object</code> <code class="plain">sender, EventArgs e) </code></span></span></div><div class="line alt2"><code class="number">10.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain">{ </code></span></span></div><div class="line alt1"><code class="number">11.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">ContactEventArgs args = </code><code class="keyword">new</code> <code class="plain">ContactEventArgs(); </code></span></span></div><div class="line alt2"><code class="number">12.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">args.Name = txtName.Text; </code></span></span></div><div class="line alt1"><code class="number">13.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">args.Email = txtEmail.Text; </code></span></span></div><div class="line alt2"><code class="number">14.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">args.Message = txtMessage.Text; </code></span></span></div><div class="line alt1"><code class="number">15.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">OnContacting(args); </code></span></span></div><div class="line alt2"><code class="number">16.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">View activeView = Model.ProcessState == enProcessState.Saved ? vSaved : vContact; </code></span></span></div><div class="line alt1"><code class="number">17.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 56px! important;"><code class="plain">mv.SetActiveView(activeView); </code></span></span></div><div class="line alt2"><code class="number">18.</code><span class="content"><code class="spaces"> </code><span class="block" style="margin-left: 28px! important;"><code class="plain">} </code></span></span></div><div class="line alt1"><code class="number">19.</code><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">}</code></span></span></div><div class="line alt1"><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain"></code></span></span> </div><div class="line alt1"><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain">READ MORE>></code></span></span></div><div class="line alt1"><span class="content"><span class="block" style="margin-left: 0px! important;"><code class="plain"><a href="http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx">http://dotnetslackers.com/articles/aspnet/Getting-started-with-testing-an-ASP-NET-Webforms-Application-MVP-Pattern.aspx</a></code></span></span></div></div></div></span></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-43953986882021847302011-05-03T23:52:00.000-07:002011-05-03T23:52:21.231-07:00CUDA integration with C#<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">CUDA enabled hardware and .NET 4 (Visual Studio 2010 IDE or C# Express 2010) is needed to successfully run the example code. Visual C++ Express 2008 has been used as a CUDA C editor (2010 version has changed custom build rules feature and cannot work with that provided by CUDA SDK for easy VS integration).</span> <br />
<a name='more'></a><br />
<br />
<b>Part 1: Environment and tools configuration for CUDA</b><br />
<br />
CUDA is a general purpose parallel computing architecture introduced by NVIDIA. CUDA programs (kernels) run on GPU instead of CPU for better performance (hundreds of cores that can collectively run thousands of computing threads). It comes with a software environment that allows developers to use C as a high-level programming language. This computation technology is used in mathematics, science, finance, modeling, image processing and so on. <br />
<br />
<b>Basic CUDA configuration for developing purpose:</b><br />
<ul><li><span style="font-family: Verdana;">Download and install CUDA toolkit for correct OS, use version 3.1 or latest 3.2RC or version 3.0 for device emulation (limited usage but works without CUDA enabled device, not supported after version 3.0)<br />
</span> </li>
<li><span style="font-family: Verdana;">Download and install SDK for the same OS and toolkit version<br />
</span> </li>
<li><span style="font-family: Verdana;">Update display drivers if you encounter problems with SDK installation</span></li>
</ul><br />
<span style="font-family: Verdana;"><b>Visual C++ Express 2008 (or VS2008) configuration:</b><br />
<br />
<b>1. Syntax coloring</b></span> <br />
<ul><li><span style="font-family: Verdana;">Open Tools -> Options from main window, then Text Editor -> File Extension, add .cu and .cuh<br />
extensions with Microsoft Visual C++ Editor</span> </li>
<li><span style="font-family: Verdana;">Copy file usertype.dat from [sdk dir]\C\doc\syntax_highlighting\visual_studio_8\ to Program<br />
Files\Microsoft Visual Studio 9.0\Common7\IDE\ folder</span> </li>
<li><span style="font-family: Verdana;">Restart Visual Studio</span></li>
</ul><br />
<span style="font-family: Verdana;"><b>2. New project, 32bit Windows XP version</b></span> <br />
<ul><li><span style="font-family: Verdana;">Default SDK location is c:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\<br />
</span> </li>
<li><span style="font-family: Verdana;">Default toolkit location is <a href="">C:\CUDA\</a></span> </li>
<li><span style="font-family: Verdana;">Create empty Win32 console application and add source file with .cu extension</span> </li>
<li><span style="font-family: Verdana;">Select newly created project in the Solution Explorer window and then right mouse key ï‚® Custom Build Rules, use Find Existing button to locate Cuda.rules file in [sdk dir] \C\common\ folder, add it and mark on the list of available rule files<br />
</span> </li>
<li><span style="font-family: Verdana;">Select again project -> Properties, select Release Configuration and then from the tree view:<br />
<br />
- Configuration Properties -> Linker -> General -> Additional Library Directories:<br />
add this line (default folders) C:\CUDA\lib;"C:\Documents and Settings\All Users\Application<br />
Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\common\lib"<br />
</span> </li>
<li><span style="font-family: Verdana;">Configuration Properties -> Linker -> Input -> Additional Dependencies: cudart.lib</span> </li>
<li><span style="font-family: Verdana;">Use the same settings for Debug Configuration</span> </li>
<li><span style="font-family: Verdana;">For emulator configurations use Configuration Manager to add new configurations based on Release and Debug ones, name them as EMU-Release and EMU-Debug (or as you wish)</span> </li>
<li><span style="font-family: Verdana;">Select EMU-Release from Configuration combo-box:<br />
<br />
- Change cudart.lib to cudartemu.lib<br />
- From tree view select CUDA Build Rule v3.0.14 (or similar) ï‚® General and set Emulation Mode to<br />
Yes<br />
</span> </li>
<li><span style="font-family: Verdana;">Do the same for EMU-Debug</span></li>
</ul><br />
<span style="font-family: Verdana;"><b>3. New project, 64bit Windows 7 version</b></span> <br />
<ul><li><span style="font-family: Verdana;">Default SDK location is c:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK\</span> </li>
<li><span style="font-family: Verdana;">Default toolkit location is <a href="">C:\CUDA\</a></span> </li>
<li><span style="font-family: Verdana;">The rest is basically similar to win32 variant except that:<br />
<br />
- Use Configuration Manager to create new solution configurations AMD64_Release, AMD64_Debug<br />
and emulation versions if needed (copy settings from Release and Debug configurations)<br />
- Use Configuration Manager to add new solution platform x64 and copy setting from Win32<br />
- In Project contexts window choose platform x64 for all AMD64 configurations<br />
- Linker -> General -> Additional Library Directories: c:\CUDA\lib64; "c:\ProgramData\NVIDIA<br />
Corporation\NVIDIA GPU Computing SDK\C\common\lib"<br />
- Linker -> Input - Additional Dependencies: cudart.lib</span></li>
</ul><br />
<span style="font-family: Verdana;"><b>Important notes about example files:</b><br />
<br />
You must do this basic configuration to be able to open attached example because of custom build rule entry in project solution file. VC++ 2008 will show errors if that rule won't be accessible due to wrong paths. You can also edit file cudalib.vcproj (*.vcproj) and fix path to cuda.rules file.<br />
<br />
If this won't help then just create new project, manually add custom build rule as described before in configuration section and then copy source .cu file from the example to that new project.<br />
<br />
You need also manually copy file cutil.h from \NVIDIA GPU Computing SDK\C\common\inc\ dir to C:\CUDA\include\ (it is easiest way to fix import paths) and add cutil32.lib (or cutil64.lib for 64bit OS) to linker input additional dependencies -> should be now like this: cudart.lib cutil32.lib (already done in example projects).<br />
<br />
CUDA toolkit and SDK version 3.0 had been used to build dll part.<br />
<br />
The main project part (written in C#) will work even without this steps because I added already built dll library to \bin\Debug and \bin\Release folders (you have to remember to replace it if you change anything in the dll part – this is not done automatically – at least in my example).<br />
<br />
And you need VS 2010 version for C# project part because .NET 4 features has been used.<br />
<br />
<b>Part 2: CUDA DLL </b><br />
<br />
The dll part code has been written in VC++ 2008 IDE. Assuming that IDE is configured properly create new Win32 Console Application, switch application type to "DLL" and mark "Empty project" (no need precompiled header and/or dllmain() function). Add new source file and save it with .cu extension. Syntax coloring should work. Remember to add CUDA custom build rule and linker dependencies.<br />
<br />
To run CUDA kernel (function executed on the GPU device) we need some sort of wrapper function exposed outside the dll. Kernel setup and invocation will be inside that function. The nice feature is that we can pass kernel execution configuration parameters to it (grid size, block size and shared memory size) instead of set them to constants which gives us possibility to run benchmark on target machine to determine best values (and so on).<br />
</span><span style="color: green; font-family: Verdana;">// cuda wrapper function</span><span style="color: blue; font-family: Verdana;">extern</span><span style="font-family: Verdana;"> <span style="color: #a31515;">"C"</span> <span style="color: blue;">int</span> <span style="color: blue;">__declspec</span>(<span style="color: blue;">dllexport</span>) <span style="color: blue;">__stdcall</span> SomeCalculationsCU<br />
(<br />
<span style="color: blue;">float</span> *a_h, <span style="color: green;">// pointer to input array</span> <span style="color: blue;">const</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> N, <span style="color: green;">// input array size</span> <span style="color: blue;">const</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> M, <span style="color: green;">// kernel M parameter</span> <span style="color: blue;">const</span> <span style="color: blue;">int</span> cuBlockSize = 512, <span style="color: green;">// kernel block size (max 512)</span> <span style="color: blue;">const</span> <span style="color: blue;">int</span> showErrors = 1 <span style="color: green;">// show CUDA errors in console window</span> )<br />
{<br />
<span style="color: blue;">int</span> tmp = PRINT_ERRORS;<br />
PRINT_ERRORS = showErrors;<br />
<br />
<span style="color: blue;">float</span> *a_d; <span style="color: green;">// pointer to device array</span> size_t size = N * <span style="color: blue;">sizeof</span>(<span style="color: blue;">float</span>);<br />
<span style="color: blue;">int</span> cuerr = 0; <span style="color: green;">// no errors</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> timer = 0;<br />
<br />
cudaMalloc((<span style="color: blue;">void</span>**)&a_d, size); <span style="color: green;">// allocate array on device </span> cudaMemcpy(a_d, a_h, size, cudaMemcpyHostToDevice);<br />
<br />
<span style="color: blue;">int</span> n_blocks = N / cuBlockSize + (N % cuBlockSize == 0 ? 0 : 1);<br />
<br />
cutCreateTimer(&timer); <span style="color: green;">// from cutil.h</span> cutStartTimer(timer);<br />
some_calculations <<<n_blocks, cuBlockSize>>> (a_d, N, M); <span style="color: green;">// kernel invocation</span> cudaThreadSynchronize(); <span style="color: green;">// by default kernel runs in parallel with CPU<br />
code</span> cutStopTimer(timer);<br />
<br />
cuerr = checkCUDAError(<span style="color: #a31515;">"cuda kernel"</span>);<br />
<br />
cudaMemcpy(a_h, a_d, size, cudaMemcpyDeviceToHost); <br />
<span style="color: blue;">if</span>(!cuerr) cuerr = checkCUDAError(<span style="color: #a31515;">"cuda memcpy"</span>);<br />
<br />
sExecutionTime = cutGetTimerValue(timer);<br />
<br />
cudaFree(a_d);<br />
<span style="color: blue;">if</span>(!cuerr) cuerr = checkCUDAError(<span style="color: #a31515;">"cuda free"</span>);<br />
<br />
PRINT_ERRORS = tmp;<br />
<span style="color: blue;">return</span> cuerr;<br />
}</span><span style="font-family: Verdana;"><br />
<br />
The most important in that function is extern "C" int _declspec(dllexport) _stdcall part which makes it visible outside dll. The calling convention (_stdcall here) must be specified because by default C functions are using _cdecl one and .NET platform invoke use CallingConvention.Winapi which is _stdcall. More info about Win32 calling conventions is here http://unixwiz.net/techtips/win32-callconv.html. Generally important is to use the same convention for caller and callee functions and not use _stdcall with variadic ones.<br />
<br />
This function could be also the main() function in console application project so you can modify it and add some print results section if you want or just add main() function like this one:<br />
</span><span style="color: blue; font-family: Verdana;">int</span><span style="font-family: Verdana;"> main(<span style="color: blue;">void</span>)<br />
{<br />
<span style="color: blue;">float</span> *a_h;<br />
<span style="color: blue;">const</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> N = 2000;<br />
<span style="color: blue;">const</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> M = 10;<br />
<span style="color: blue;">const</span> <span style="color: blue;">int</span> cublocks = 256;</span> <br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"> size_t size = N * <span style="color: blue;">sizeof</span>(<span style="color: blue;">float</span>);<br />
a_h = (<span style="color: blue;">float</span>*)malloc(size);<br />
<span style="color: blue;">for</span>(<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> i = 0; i < N; i++) a_h[i] = (<span style="color: blue;">float</span>)i;<br />
<br />
SomeCalculationsCU(a_h, N, M, cublocks, 1);<br />
<br />
printf(<span style="color: #a31515;">"exec time = %f ms\n"</span>, sExecutionTime);<br />
}</span><span style="font-family: Verdana;"><br />
<br />
To run this as an application (not build dll) change Configuration Type to Application (.exe) in project properties -> Configuration Properties -> General section. This also allows you to use CUDA Profiler (located in C:\CUDA\cudaprof\bin\ directory).<br />
<br />
File dllmain.cu has also example of variable available to access from the outside of dll:<br />
</span><span style="color: green; font-family: Verdana;">// external variable example</span><span style="color: blue; font-family: Verdana;">extern</span><span style="font-family: Verdana;"> <span style="color: #a31515;">"C"</span> { <span style="color: blue;">float</span> <span style="color: blue;">__declspec</span>(<span style="color: blue;">dllexport</span>) sExecutionTime = -1; }</span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: green; font-family: Verdana;">// variable wrapper function</span><span style="color: blue; font-family: Verdana;">extern</span><span style="font-family: Verdana;"> <span style="color: #a31515;">"C"</span> <span style="color: blue;">float</span> <span style="color: blue;">__declspec</span>(<span style="color: blue;">dllexport</span>) <span style="color: blue;">__stdcall</span> GetExecutionTime()<br />
{<br />
<span style="color: blue;">return</span> sExecutionTime;<br />
}</span><span style="font-family: Verdana;"><br />
<br />
It is possible to access that kind of variable directly (will be shown in C# part) but this is much easier with wrapper functions approach (could works like get/set accessors).<br />
<br />
Finally example kernel function:<br />
</span><span style="color: green; font-family: Verdana;">// cuda kernel (internal)</span><span style="color: blue; font-family: Verdana;">__global__</span><span style="font-family: Verdana;"> <span style="color: blue;">void</span> some_calculations(<span style="color: blue;">float</span> *a, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> N, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> M)<br />
{<br />
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> idx = <span style="color: blue;">blockIdx</span>.x * <span style="color: blue;">blockDim</span>.x + <span style="color: blue;">threadIdx</span>.x; <br />
<span style="color: blue;">if</span> (idx < N)<br />
{<br />
<span style="color: green;">// note1: no need for shared memory here</span> <span style="color: green;">// note2: global memory access is coalesced</span> <span style="color: green;">// (no structs, float only used)</span></span><span style="color: green; font-family: Verdana;"> </span><span style="font-family: Verdana;"> <span style="color: green;">// do computations M times on each thread</span> <span style="color: green;">// to extend processor's time</span> <span style="color: blue;">for</span>(<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> i = 0; i < M; i++)<br />
{<br />
<span style="color: green;">// some easy arithmetics </span> a[idx] = a[idx] * a[idx] * 0.1 - a[idx] - 10;<br />
}<br />
}<br />
}</span><span style="font-family: Verdana;"><br />
And CPU version for execution time comparison:<br />
</span><span style="color: blue; font-family: Verdana;">extern</span><span style="font-family: Verdana;"> <span style="color: #a31515;">"C"</span> <span style="color: blue;">void</span> <span style="color: blue;">__declspec</span>(<span style="color: blue;">dllexport</span>) <span style="color: blue;">__stdcall</span> SomeCalculationsCPU<br />
(<br />
<span style="color: blue;">float</span> *a_h, <br />
<span style="color: blue;">const</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> N,<br />
<span style="color: blue;">const</span> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> M<br />
)</span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"> <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> timer = 0;<br />
cutCreateTimer(&timer);<br />
cutStartTimer(timer);<br />
<span style="color: blue;">for</span>(<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> i = 0; i < N; i++)<br />
<span style="color: blue;">for</span>(<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> j = 0; j < M; j++)<br />
</span><span lang="PL" style="font-family: Verdana;">*(a_h + i) = *(a_h + i) * *(a_h + i) * 0.1 - *(a_h + i) - 10;<br />
</span><span style="font-family: Verdana;">cutStopTimer(timer);<br />
sExecutionTime = cutGetTimerValue(timer);<br />
}</span><span style="font-family: Verdana;"><br />
<br />
READ MORE>></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><a href="http://www.c-sharpcorner.com/UploadFile/rafaelwo/4398/">http://www.c-sharpcorner.com/UploadFile/rafaelwo/4398/</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-61980507342932041112011-05-02T21:47:00.000-07:002011-05-26T00:47:43.963-07:00Playing and Controlling Video Playback in XAML Silverlight<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-family: Verdana, sans-serif;">Using videos in a Silverlight based application is a very exciting feature that come early Silverlight 2. Today we see the most extended Silverlight specially Microsoft added GPU Hardware Acceleration for video and bitmap in Silverlight 3 and now Silverlight 4 supports the output protection for video and audio.</span></span><br />
<a name='more'></a><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-family: Verdana, sans-serif;"><br />
</span></span><br />
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"></span><br />
<div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><b><span style="font-family: Verdana, sans-serif; line-height: 115%;">How to Play Video</span></b> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-size: small;">To play the video, we can simply drag the compatible [</span></span><a href="http://www.msdn.microsoft.com/en-us/library/cc189080%28v=vs.95%29.aspx"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-size: small;">List of Supported Media Formats</span></span></a><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">] video file on the development stage. </span><span style="font-family: Verdana, sans-serif; line-height: 115%;">Now, if you add videos in the development stage and test it, then it will have the following three annoying work:</span> </span></span></div><ol><li><div class="MsoListParagraphCxSpFirst" style="margin-left: 0.75in; text-align: justify; text-indent: -0.5in;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">Movie will automatically start</span> </span></span></div></li>
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;">
<li><div class="MsoListParagraphCxSpMiddle" style="margin-left: 0.75in; text-align: justify; text-indent: -0.5in;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">Movie runs untill the end and when reaches at end can't run again</span> </span></div></li>
<li><div class="MsoListParagraphCxSpLast" style="margin-left: 0.75in; text-align: justify; text-indent: -0.5in;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">Once movie starts there is no way to stop or pause this</span> </span></div></li>
</span></ol><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">But by using some coding in code-behind we can control the playback of movie. Let's see how!</span> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><b><span style="font-family: Verdana, sans-serif;">1.</span></b><b><span style="font-family: Verdana, sans-serif; line-height: 115%;"> Dealing with Automatic Start</span></b> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-size: small;">By default videos automaticall get started when we run the project, it is distracting feature from the users point of view. To change auto start false, select the video on stage and in properties uncheck the 'AutoPlay' option. </span></span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-size: small;"></span></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><img alt="image002.jpg" border="0" height="650px" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7115/Images/image002.jpg" width="595px" /><br />
</span> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><b><span style="font-family: Verdana, sans-serif;">2.</span></b><b><span style="font-family: Verdana, sans-serif; line-height: 115%;"> Dealing with Endless Playback</span></b> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">By default, when the video reaches the end then it stops and does not start again. To change such a setting follow the steps:</span> </span></span></div><ol><li><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">Select the video on stage</span> </span></span></div></li>
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;">
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: small;">In Properties, switch the mode from 'Properties' to 'Events'. </span></div></li>
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">In the Event list, point to 'MediaEnded' label and type the event handler name (I will be using md_ended_eve) and then press tab to apply it and it automatically switches you to code-behind with a new event.</span> </span></div></li>
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">Now type the following code inside event handler. <br />
<br />
(intro_wmv).Stop();<br />
(intro_wmv).Play();<br />
<br />
In above code 'intro_wmv' is my media fine name.<br />
</span> </span></div></li>
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">Now test the application.</span> </span></div></li>
</span></ol><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-size: small;">Note to use 'AutoPlay' to true when you are testing endless loop. </span></span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><span style="font-size: small;"></span></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><b><span style="font-family: Verdana, sans-serif; line-height: 115%;">XAML Code</span></b> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"></span> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><Grid<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
x:Class="SilverlightApplication1.MainPage"<br />
Width="640" Height="480"><br />
<MediaElement x:Name="intro_wmv" <br />
Margin="54,64,104,60" <br />
Source="/intro.wmv" <br />
Stretch="Fill" <br />
MediaEnded="md_ended_eve" AutoPlay="False"/><br />
</Grid><br />
</span> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><b><span style="font-family: Verdana, sans-serif; line-height: 115%;">XAML.CS Code</span></b> </span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="color: blue; font-family: Verdana, sans-serif;"><span style="font-size: small;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Controls;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Documents;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Ink;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Input;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Media;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Media.Animation;</span><span style="color: blue; font-family: Verdana, sans-serif;">using</span><span style="color: black; font-family: Verdana, sans-serif;"> System.Windows.Shapes;</span></span><span style="color: blue; font-family: Verdana, sans-serif;"><br />
<span style="font-size: small;">namespace</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> SilverlightApplication1<br />
{<br />
</span><span style="color: blue; font-family: Verdana, sans-serif;">public</span><span style="color: black; font-family: Verdana, sans-serif;"> </span><span style="color: blue; font-family: Verdana, sans-serif;">partial</span><span style="color: black; font-family: Verdana, sans-serif;"> </span><span style="color: blue; font-family: Verdana, sans-serif;">class</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> MainPage : Grid<br />
{<br />
</span><span style="color: blue; font-family: Verdana, sans-serif;">public</span></span><span style="color: black; font-family: Verdana, sans-serif;"><span style="font-size: small;"> MainPage()<br />
{<br />
</span></span><span style="color: green; font-family: Verdana, sans-serif;"><span style="font-size: small;">// Required to initialize variables</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> InitializeComponent();<br />
}<br />
</span><span style="color: blue; font-family: Verdana, sans-serif;">private</span><span style="color: black; font-family: Verdana, sans-serif;"> </span><span style="color: blue; font-family: Verdana, sans-serif;">void</span><span style="color: black; font-family: Verdana, sans-serif;"> md_ended_eve(</span><span style="color: blue; font-family: Verdana, sans-serif;">object</span></span><span style="color: black; font-family: Verdana, sans-serif;"><span style="font-size: small;"> sender, System.Windows.RoutedEventArgs e)<br />
{<br />
</span></span><span style="color: green; font-family: Verdana, sans-serif;"><span style="font-size: small;">// TODO: Add event handler implementation here.</span></span><span style="font-size: small;"><span style="color: black; font-family: Verdana, sans-serif;"> (intro_wmv).Stop();<br />
(intro_wmv).Play();<br />
}<br />
<br />
}</span><span style="color: black; font-family: Verdana, sans-serif; line-height: 115%;">}</span> </span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><br />
</span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"><img alt="image004.jpg" border="0" height="421px" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7115/Images/image004.jpg" width="623px" /><br />
</span> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana, sans-serif; line-height: 115%;"></span><span style="font-size: small;"> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><b><span style="font-family: Verdana, sans-serif; line-height: 115%;">3. Control Video Playback by Pause and Play</span></b> </span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"> </span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif; line-height: 115%;">By default in Silverlight video plays and we can't control it by pausing and playing. But by writing some lines in code-behind we can control this playback. For this we have to create the event as we saw in above example. Let's follow the steps:</span> </span></span></div><ul><li><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">Open the event explorer by switching the property (look above image).</span> </span></span></div></li>
<span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;">
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">Type the event name in 'MouseLeftButtonDown', I will be using here 'pause_start_evn' and press tab to switch in event handler mode.<br />
</span> </span></div></li>
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">In the appeared event type the following code:<br />
<br />
private bool IsPaused=true;<br />
private void pause_start_evn(object sender, System.Windows.Input.MouseButtonEventArgs e)<br />
{<br />
// TODO: Add event handler implementation here.<br />
if(IsPaused)<br />
{<br />
(intro_wmv as MediaElement).Play();<br />
IsPaused=false;<br />
}<br />
else<br />
{<br />
(intro_wmv as MediaElement).Pause();<br />
IsPaused=true;<br />
}<br />
}<br />
<br />
In the above code, 'intro_wmv' is my media file name. <br />
</span> </span></div></li>
<li><div class="MsoNormal" style="text-align: justify;"><span style="font-size: small;"><span style="font-family: Verdana, sans-serif;">Now test the application and check by right mouse click on video surface.</span> </span></div></li>
</span></ul><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><span style="font-size: small;">READ MORE>></span></span></div><div class="MsoNormal" style="text-align: justify;"><span style="font-family: Verdana, sans-serif; font-size: 10pt; line-height: 115%;"><a href="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7115/"><span style="font-size: small;">http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/7115/</span></a></span></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-90448274511906133842011-05-01T21:38:00.000-07:002011-05-01T21:38:12.699-07:00Silverlight Bing Map Control in SharePoint 2010<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">Silverlight Bing Map Control in SharePoint 2010<br />
<br />
In this article we will be seeing how to use Silverlight Bing map control in SharePoint 2010.</span><br />
<a name='more'></a><br />
<br />
<b>Bing Map Developer Account:</b><br />
<ul><li><span style="font-family: Verdana;">Open <a href="https://www.bingmapsportal.com/">https://www.bingmapsportal.com/</a>.<br />
<br />
<img alt="BingSilver1.gif" border="0" height="320px" src="http://www.c-sharpcorner.com/UploadFile/anavijai/7108/Images/BingSilver1.gif" width="596px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Go to New User section and click on Create.<br />
<br />
<img alt="BingSilver2.gif" border="0" height="215px" src="http://www.c-sharpcorner.com/UploadFile/anavijai/7108/Images/BingSilver2.gif" width="585px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Sign in using Windows Live ID.</span> </li>
<li><span style="font-family: Verdana;">Enter the account details and click on Save.<br />
<br />
<img alt="BingSilver3.gif" border="0" height="559px" src="http://www.c-sharpcorner.com/UploadFile/anavijai/7108/Images/BingSilver3.gif" width="401px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Bing Map Developer account will be created successfully.<br />
<br />
<img alt="BingSilver4.gif" border="0" height="512px" src="http://www.c-sharpcorner.com/UploadFile/anavijai/7108/Images/BingSilver4.gif" width="401px" /></span></li>
</ul><span style="font-family: Verdana;"><b>Bing Maps Key:</b><br />
<br />
Bing Maps Key should be created to authenticate your Bing Maps application as described in the SDK for the Bing Maps API we are using. If you run the program without providing the valid Bind Maps Key then the map appears in the browser with a message that you have invalid credential appears.<br />
<br />
• Select Create or view keys in the Tasks left-hand menu MAP APIs.<br />
<br />
<img alt="BingSilver5.gif" border="0" height="77px" src="http://www.c-sharpcorner.com/UploadFile/anavijai/7108/Images/BingSilver5.gif" width="218px" /><br />
<br />
<br />
• In the Create key box on the My keys page, provide the following information for the application that will use the Bing Maps key:</span><br />
<ul><li><span style="font-family: Verdana;">Application name Required. The name of the application.</span> </li>
<li><span style="font-family: Verdana;">Application URL Required. The URL of the application.</span> </li>
<li><span style="font-family: Verdana;">Application Type Required. The scenario for your application. Select the application type that best represents the application that will use this key.<br />
<br />
The following are general descriptions of these types. <br />
</span> <table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin-left: 66pt; width: 88%;"><tbody>
<tr style="height: 15.75pt;"><td style="background: rgb(229,229,229); border-bottom: rgb(187,187,187) 1pt solid; border-left: rgb(187,187,187) 1pt solid; border-right: rgb(187,187,187) 1pt solid; border-top: rgb(187,187,187) 1pt solid; height: 15.75pt; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application Type </span></div></td><td style="background: rgb(229,229,229); border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: 1pt solid; height: 15.75pt; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Description </span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Broadcast</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application is used for public or internal-facing television, movies or similar.</span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Developer</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application does not exceed 125,000 sessions or 500,000 transactions within a 12 month period.</span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Education</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application is used for public use by schools, including faculty, staff and students.</span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Evaluation/Trial</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application is used for public or internal use during a 90 day evaluation period.</span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Mobile</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application is used for publically available and installable applications on mobile handsets.</span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Not-for-profit</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Application is used by a tax-exempt organization.</span></div></td></tr>
<tr><td style="background: white; border-bottom: 1pt solid; border-left: 1pt solid; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">Enterprise</span></strong><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;"> </span></div></td><td style="background: white; border-bottom: 1pt solid; border-left: medium none; border-right: 1pt solid; border-top: medium none; padding-bottom: 3pt; padding-left: 3pt; padding-right: 3pt; padding-top: 3pt;" valign="top"><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><span style="color: black; font-family: Verdana,sans-serif; line-height: 150%;">This option is available to licensed enterprise accounts only.</span></div><div class="MsoNormal" style="line-height: 150%; margin: 9.75pt 0.75pt;"><br />
</div></td></tr>
</tbody></table></li>
</ul>READ MORE >><br />
<a href="http://www.c-sharpcorner.com/UploadFile/anavijai/7108/">http://www.c-sharpcorner.com/UploadFile/anavijai/7108/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-27349882862673131842011-04-28T21:40:00.000-07:002011-04-28T21:40:20.599-07:00Security model of Internet Information Services for ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">IIS has its own security configuration and even for any request reaching the ASP.NET runtime, IIS verifies the request with it's own security configuration. So the first gatekeeper in the ASP.NET security pipeline is actually IIS. So let us understand those security mechanisms which IIS implements:</span> <br />
<a name='more'></a><br />
<span style="font-family: Verdana;"><b>1. Authentication: IIS support following authentication mechanism</b></span> <br />
<ul><li><span style="font-family: Verdana;">Basic authentication:</span> </li>
<li><span style="font-family: Verdana;">Digest authentication</span> </li>
<li><span style="font-family: Verdana;">Passport authentication</span> </li>
<li><span style="font-family: Verdana;">Window authentication</span> </li>
<li><span style="font-family: Verdana;">Certificate authentication</span></li>
</ul><br />
<span style="font-family: Verdana;"><b>Point to remember:</b></span> <br />
<ol><li><span style="font-family: Verdana;">Any authentication which IIS performs results into an authenticated window user, so this means that IIS supports authenticating window users only.</span> </li>
<li><span style="font-family: Verdana;">If ASP.NET is configured to support form or window authentication, then configure IIS to support basic or digest authentication.</span> </li>
<li><span style="font-family: Verdana;">If ASP.NET is configured to support form or custom authentication, then configure IIS to support anonymous access.</span> </li>
<li><span style="font-family: Verdana;">With XP, it comes with IIS 5.x </span></li>
<li><span style="font-family: Verdana;">With Server 2003, it is IIS 6.0</span></li>
</ol><br />
<span style="font-family: Verdana;"><b>How to configure IIS for authentication:</b><br />
<br />
<b>Point to member here</b></span> <br />
<ol><li><span style="font-family: Verdana;">When the Anonymous User option is checked then everyone is given access to a web page and it overrides all authentication settings.<br />
</span> </li>
<li><span style="font-family: Verdana;">If IIS is configured to anonymous authentication, we can still use ASP.NET-based security to authenticate users either with ASP.NET-integrated mechanisms such as forms authentication or a custom type of authentication.<br />
<br />
<img alt="IIS1.gif" border="0" height="589px" src="http://www.c-sharpcorner.com/UploadFile/37db1d/7053/Images/IIS1.gif" width="555px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Windows authentication configures IIS to validate the credentials of the user against a Windows account configured either on the local machine or within the domain. A Credential submitted by a user is verified against the Windows account.<br />
</span> </li>
<li><span style="font-family: Verdana;">When Basic Authentication is checked it defines an additional HTTP header for transmitting user names and password across the wire but nothing is encrypted here. It is transmitted in the form of a base64 encoding.<br />
<br />
<img alt="IIS2.gif" border="0" height="432px" src="http://www.c-sharpcorner.com/UploadFile/37db1d/7053/Images/IIS2.gif" width="371px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Digest authentication is similar to basic authentication with the difference that instead of sending credentials in the form of Base64 encoding, user password and username are hashed. </span></li>
</ol><br />
READ MORE >><br />
<a href="http://www.c-sharpcorner.com/UploadFile/37db1d/7053/">http://www.c-sharpcorner.com/UploadFile/37db1d/7053/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-7694198193748286542011-04-27T21:39:00.000-07:002011-04-27T21:39:19.631-07:00Database Binding with Accordion Control<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">This article demonstrates how to bind an Accordion Control with a database in ASP.Net using Ajax.<br />
<br />
We are assuming that you have already completed the installation of the Ajax Toolkit as well as have a basic understanding of coding.</span><br />
<a name='more'></a><br />
<br />
<b>About the control:</b><br />
<br />
The Accordion is a web control that allows you to provide multiple panes and display them one at a time. It is like having several CollapsiblePanels where only one can be expanded at a time. The Accordion is implemented as a web control that contains AccordionPane web controls. Each AccordionPane control has a template for its Header and its Content. We keep track of the selected pane so it stays visible across postbacks. <br />
<br />
It also supports three AutoSize modes so it can fit in a variety of layouts. <br />
<ul><li><span style="font-family: Verdana;"><b>None </b>- The Accordion grows/shrinks without restriction. This can cause other elements on your page to move up and down with it.</span> </li>
<li><span style="font-family: Verdana;"><b>Limit </b>- The Accordion never grows larger than the value specified by its Height property. This will cause the content to scroll if it is too large to be displayed.</span> </li>
<li><span style="font-family: Verdana;"><b>Fill </b>- The Accordion always stays the exact same size as its Height property. This will cause the content to be expanded or shrunk if it isn't the right size.</span></li>
</ul><br />
<span style="font-family: Verdana;">The Accordion is written using an extender like most of the other extenders in the AJAX Control Toolkit. The extender expects its input in a very specific hierarchy of container elements (like divs), so the Accordion and AccordionPane web controls are used to generate the expected input for the extender. The extender can also be used on its own if you provide it appropriate input.<br />
<br />
This article provides a few steps which will be easy to follow.<br />
<br />
<b>Step 1:</b><br />
<br />
Before you can use any of the Ajax Control Toolkit controls in a page, you first need to add a ScriptManager to the page. You can drag the ScriptManager from the Visual Studio Toolbox window onto the page. The ScriptManager is located in the Ajax Control Toolkit tab under the Toolbox.<br />
</span><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">asp</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">ScriptManager</span><span style="font-family: Verdana;"> <span style="color: red;">ID</span><span style="color: blue;">="ScriptManager1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span></span><span style="font-family: Verdana; line-height: 115%;"> <span style="color: blue;"></</span><span style="color: #a31515;">asp</span><span style="color: blue;">:</span><span style="color: #a31515;">ScriptManager</span><span style="color: blue;">></span></span><span style="font-family: Verdana;"><br />
<b>Step 2:</b><br />
<br />
Create one which is like: <br />
</span><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">style</span><span style="font-family: Verdana;"> <span style="color: red;">type</span><span style="color: blue;">="text/css"></span></span> <br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: #a31515; font-family: Verdana;">.accordion-header</span><span style="font-family: Verdana;">, <span style="color: #a31515;">.accordion-selected</span> {</span><span style="color: red; font-family: Verdana;">width</span><span style="font-family: Verdana;">: <span style="color: blue;">300px</span>;</span><span style="color: red; font-family: Verdana;">background-color</span><span style="font-family: Verdana;">: <span style="color: blue;">#c0c0c0</span>;</span><span style="color: red; font-family: Verdana;">margin-bottom</span><span style="font-family: Verdana;">:<span style="color: blue;">2px</span>;</span><span style="color: red; font-family: Verdana;">padding</span><span style="font-family: Verdana;">:<span style="color: blue;">2px</span>;</span><span style="color: red; font-family: Verdana;">color</span><span style="font-family: Verdana;">:<span style="color: blue;">#444444</span>;</span><span style="color: red; font-family: Verdana;">font-weight</span><span style="font-family: Verdana;">:<span style="color: blue;">bold</span>;</span><span style="color: red; font-family: Verdana;">cursor</span><span style="font-family: Verdana;">:<span style="color: blue;">pointer</span>;<br />
}</span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: #a31515; font-family: Verdana;">.accordion-content</span><span style="font-family: Verdana;"> {</span><span style="color: red; font-family: Verdana;">width</span><span style="font-family: Verdana;">:<span style="color: blue;">300px</span>;</span><span style="color: red; font-family: Verdana;">margin-bottom</span><span style="font-family: Verdana;">:<span style="color: blue;">2px</span>;</span><span style="color: red; font-family: Verdana;">padding</span><span style="font-family: Verdana;">:<span style="color: blue;">2px</span>;<br />
}</span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: #a31515; font-family: Verdana;">.accordion-selected</span><span style="font-family: Verdana;">, <span style="color: #a31515;">.accordion-content</span> {</span><span style="color: red; font-family: Verdana;">border</span><span style="font-family: Verdana;">:<span style="color: blue;">solid</span> <span style="color: blue;">1px</span> <span style="color: blue;">#666666</span>;<br />
}</span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: blue; font-family: Verdana;"></</span><span style="color: #a31515; font-family: Verdana;">style</span><span style="color: blue; font-family: Verdana;">></span><span style="font-family: Verdana;"><br />
<br />
<b>Step 3:</b><br />
<br />
Drag an Accordion Control from the ToolBox, which will look like:<br />
</span><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">cc1</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">Accordion</span><span style="font-family: Verdana;"> <span style="color: red;">ID</span><span style="color: blue;">="Accordion1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span></span><span style="color: blue; font-family: Verdana;"></</span><span style="color: #a31515; font-family: Verdana;">cc1</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">Accordion</span><span style="color: blue; font-family: Verdana;">></span><span style="font-family: Verdana;"> </span><span style="font-family: Verdana;"><br />
<br />
<b>Step 4:</b><br />
<br />
Apply some css on it and change its property according to the requirement.<br />
</span><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">cc1</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">Accordion</span><span style="font-family: Verdana;"> <span style="color: red;">ID</span><span style="color: blue;">="Accordion1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">TransitionDuration</span><span style="color: blue;">="100"</span> <span style="color: red;">SelectedIndex</span><span style="color: blue;">=-1</span> <span style="color: red;">FramesPerSecond</span><span style="color: blue;">="200"</span> <span style="color: red;">FadeTransitions</span><span style="color: blue;">="true"</span> <span style="color: red;">RequireOpenedPane</span><span style="color: blue;">="false"</span> <span style="color: red;">ContentCssClass</span><span style="color: blue;">="accordion-content"</span> <span style="color: red;">HeaderCssClass</span><span style="color: blue;">="accordion-header"</span> <span style="color: red;">HeaderSelectedCssClass</span><span style="color: blue;">="accordion-selected"</span> <span style="color: blue;">></span></span> </div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: blue; font-family: Verdana;"></</span><span style="color: #a31515; font-family: Verdana;">cc1</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">Accordion</span><span style="color: blue; font-family: Verdana;">></span><span style="font-family: Verdana;"><br />
<b>Step 5:</b><br />
<br />
Generate the OnItemDataBound events.<br />
<br />
Which will look like:<br />
</span><span style="color: blue; font-family: Verdana;"><</span><span style="color: #a31515; font-family: Verdana;">cc1</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">Accordion</span><span style="font-family: Verdana;"> <span style="color: red;">ID</span><span style="color: blue;">="Accordion1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">TransitionDuration</span><span style="color: blue;">="100"</span> <span style="color: red;">SelectedIndex</span><span style="color: blue;">=-1</span> <span style="color: red;">FramesPerSecond</span><span style="color: blue;">="200"</span> <span style="color: red;">FadeTransitions</span><span style="color: blue;">="true"</span> <span style="color: red;">RequireOpenedPane</span><span style="color: blue;">="false"</span> <span style="color: red;">OnItemDataBound</span><span style="color: blue;">="Accordion1_ItemDataBound"</span> <span style="color: red;">ContentCssClass</span><span style="color: blue;">="accordion-content"</span> <span style="color: red;">HeaderCssClass</span><span style="color: blue;">="accordion-header"</span> <span style="color: red;">HeaderSelectedCssClass</span><span style="color: blue;">="accordion-selected"</span> <span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana;"></</span><span style="color: #a31515; font-family: Verdana;">cc1</span><span style="color: blue; font-family: Verdana;">:</span><span style="color: #a31515; font-family: Verdana;">Accordion</span><span style="color: blue; font-family: Verdana;">></span><span style="font-family: Verdana;"><br />
<br />
READ MORE >></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><a href="http://www.c-sharpcorner.com/UploadFile/cd3aa3/7031/">http://www.c-sharpcorner.com/UploadFile/cd3aa3/7031/</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-26040184720263087852011-04-26T21:23:00.000-07:002011-04-26T21:23:31.170-07:00Hosting Mobile WebSite Under IIS<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">First we have to create a mobile web application. For how to create a mobile web site see my previous article Developing Mobile Pages. </span> <br />
<a name='more'></a><br />
<br />
Once we have created our mobile pages the testing of the mobile pages is not as easy as you think; for testing of mobile pages you can use desktop browsers as well as Mobile Emulators. With desktop browsers you can test by direst debugging application but in mobile emulators first we have to host our website under IIS. For testing mobile pages in an emulator we have to host the website first under IIS.<br />
<br />
<b>Hosting Website:</b><br />
<br />
Check out the following screenshot which will help you to host the website under IIS.<br />
<ol><li><span style="font-family: Verdana;">Open IIS Manager<br />
<br />
<img alt="HosWebSite1.gif" border="0" height="470px" src="http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/Images/HosWebSite1.gif" width="623px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Right click on Default Web Site->New->Virtual Directory which will open the following screen.<br />
<br />
<img alt="HosWebSite2.gif" border="0" height="379px" src="http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/Images/HosWebSite2.gif" width="482px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">Provide a virtual name by which you want to access your website while typing URL. And click on next.</span> </li>
<li><span style="font-family: Verdana;">The next screen will ask you to provide the physical content of your application.<br />
<br />
<img alt="HosWebSite3.gif" border="0" height="380px" src="http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/Images/HosWebSite3.gif" width="485px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">On the next screen it will ask you the permission setting for you website. Select all permission and click on next and then finish.<br />
<br />
<img alt="HosWebSite4.gif" border="0" height="387px" src="http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/Images/HosWebSite4.gif" width="481px" /><br />
</span> </li>
<li><span style="font-family: Verdana;">After finishing website creation your web site is created.<br />
<br />
<img alt="HosWebSite5.gif" border="0" height="463px" src="http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/Images/HosWebSite5.gif" width="620px" /></span></li>
</ol><span style="font-family: Verdana;">READ MORE>></span><br />
<a href="http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/">http://www.c-sharpcorner.com/UploadFile/krishnasarala/6968/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-11466834993231005952011-04-25T21:30:00.000-07:002011-04-25T21:30:24.256-07:00What is Foreground or Background Thread<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;"></div><div style="text-align: justify;"><span style="font-family: Verdana;">Threading is a concept we all understand and most of us would have implemented them in real world applications. Here is one more explanation of inner level detail on threads - that is Foreground and Background threads.</span> </div><div align="justify"><a name='more'></a></div><div style="text-align: justify;"><br />
<br />
<b>Types of Threads</b><br />
<br />
Basically, there are two types of threads which fall into:</div><ul><li><div style="text-align: justify;"><span style="font-family: Verdana;">Foreground Thread</span> </div></li>
<li><div style="text-align: justify;"><span style="font-family: Verdana;">Background Thread</span> </div></li>
</ul><div style="text-align: justify;"><br />
<span style="font-family: Verdana;"><b>Foreground Thread</b><br />
<br />
Foreground threads are threads which will continue to run until the last foreground thread is terminated. In another way, the application is closed when all the foreground threads are stopped.<br />
<br />
So the application won't wait until the background threads are completed, but it will wait until all the foreground threads are terminated. <br />
<br />
By default, the threads are foreground threads. So when we create a thread the default value of IsBackground property would be false.<br />
<b><br />
Background Thread</b><br />
<br />
Background threads are threads which will get terminated when all foreground threads are closed. The application won't wait for them to be completed.<br />
<br />
We can create a background thread like following:<br />
</span><span lang="EN-US" style="color: #2b91af; font-family: Verdana;">Thread</span><span lang="EN-US" style="font-family: Verdana;"> backgroundThread = <span style="color: blue;">new</span> <span style="color: #2b91af;">Thread</span>(threadStart);<br />
backgroundThread.<b>IsBackground</b> = <span style="color: blue;">true</span>;<br />
backgroundThread.Start();</span><span style="font-family: Verdana;"><br />
<br />
<b>Test Application</b><br />
<br />
We can see the difference by using a windows or console application. In the attachment,provided such an application. The application is explained below:<br />
<br />
<img alt="thread1.gif" border="0" height="396px" src="http://www.c-sharpcorner.com/UploadFile/40e97e/5775/Images/thread1.gif" width="553px" /><br />
<br />
The application contains 2 buttons, on click of each it will create a thread.<br />
Each thread will be executing a method which takes 25 seconds to execute through a mere Thread.Sleep() invoke.<br />
</span><span lang="EN-US" style="color: blue; font-family: Verdana;">private</span><span lang="EN-US" style="font-family: Verdana;"> <span style="color: blue;">void</span> TenSecondsMethod()<br />
{<br />
<span style="color: green;">// Method of 25 seconds delay</span> <span style="color: #2b91af;">Thread</span>.Sleep(25000);<br />
}</span><span style="font-family: Verdana;"><br />
The first one will be Background thread and second would be Foreground.<br />
<br />
After clicking each button, you can try closing the application.<br />
<br />
From the windows task manager we can see the application would not be listed in the case of Background thread created.<br />
<br />
From the windows task manager we can see the application would be still running in the case of Foreground thread created. <br />
<br />
The following image shows the snapshot of task manager just after closing the application after invoking a foreground thread. The application will continue to run until all the foreground threads are completed.<br />
<br />
READ MORE >></span></div><div style="text-align: justify;"><a href="http://www.c-sharpcorner.com/UploadFile/40e97e/5775/">http://www.c-sharpcorner.com/UploadFile/40e97e/5775/</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-36071469483036258992011-04-24T21:41:00.000-07:002011-04-24T21:41:31.983-07:00Pop Search Form Control in Silverlight<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">Silverlight is a new and powerful browser plug-in that works with Mac OS, Windows and Linux. It helps you create rich web application that is safe, secure and scalable cross-platform. This article will use Visual Studio 2008 to create Silverlight pop search form control.</span><b style="mso-bidi-font-weight: normal;"><span style="font-family: 'Verdana','sans-serif'; font-size: 12pt; line-height: 115%; mso-fareast-font-family: 'Times New Roman';"><br />
System Requirement</span></b><br />
<a name='more'></a><br />
<ul><li>This application requires the user to have copy of Visual Studio 2008 </li>
<li>Microsoft Silverlight 2 Tools for Visual Studio 2008 SP1 (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyId=c22d6a7b-546f-4407-8ef6-d60c8ee221ed&displaylang=en</a>) </li>
<li>Northwind database in MS SQL Server </li>
</ul>The article assumes a familiarity with C#, as well as with using Visual Studio 2008 to create Silverlight applications. Elementary knowledge of WCF, Web Service, LINQ would be beneficial but not absolutely necessary to fully understand the content of this article.<br />
<b style="mso-bidi-font-weight: normal;"><span style="font-family: 'Verdana','sans-serif'; font-size: 12pt; line-height: 115%; mso-fareast-font-family: 'Times New Roman';"><br />
Design Requirement</span></b><br />
The main control is combining with two textboxes and one button as Fig 1. The first textbox has ability to display data and enter data. The button will show up pop search form. The second textbox has ability to display data only.<br />
<br />
<img alt="Fig 1. Main control with function descriptions.jpg" border="0" height="141px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%201.%20Main%20control%20with%20function%20descriptions.jpg" title="Main control with function descriptions" width="525px" /><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-bidi-language: AR-SA; mso-fareast-font-family: 新細明體; mso-fareast-language: ZH-TW; mso-no-proof: yes;"><shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><br />
<span style="font-family: Verdana; font-size: small;">Fig 1. Main Control with function descriptions</span></shapetype></span><br />
The pop search form control has datagrid to display data and it has searching function as Fig 2.<br />
<br />
<img alt="Fig 2. Pop search form control with function descriptions.jpg" border="0" height="402px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%202.%20Pop%20search%20form%20control%20with%20function%20descriptions.jpg" title="Pop search form control with function descriptions" width="434px" /><br />
Fig 2. Pop Search Form control with function descriptions<br />
<br />
There are two ways to bring data from datagrid to the main control.<br />
<ol><li>By double click datagrid </li>
<li>By click OK button</li>
</ol><img alt="Fig 3. Showing double click or button click to bring selected data back to main control.jpg" border="0" height="363px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%203.%20Showing%20double%20click%20or%20button%20click%20to%20bring%20selected%20data%20back%20to%20main%20control.jpg" title="Showing double click or button click to bring selected data back to main control" width="532px" /><br />
Fig 3. Bring selected data back to Main control<br />
<br />
There is one way to extract data without pop search form.<br />
<ol><li>Types correct ID (key) in first textbox to display Name (Value) data.</li>
</ol><img alt="Fig 4. Showing types correct ID to display Name.jpg" border="0" height="113px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%204.%20Showing%20types%20correct%20ID%20to%20display%20Name.jpg" title="Types correct ID to display Name" width="247px" /><br />
Fig 4. Types correct ID to display Name<br />
<br />
<span style="font-family: 'Verdana','sans-serif'; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-bidi-language: AR-SA; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: ZH-TW;"><strong>Create Silverlight and WCF Project</strong></span><br />
<br />
Once we know control's functionalities, now we can start to create our project in Visual Studio 2008. Let's create all the projects we need, then we will tackle each project to achieve goal.<br />
<span style="color: black; font-family: 'Verdana','sans-serif'; font-size: 12pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-bidi-language: AR-SA; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: ZH-TW;"><strong><span style="background-color: yellow;"><br />
**Please download the code and walkthrough it with each step</span></strong></span> <br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;"><u><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt; line-height: 115%; mso-fareast-font-family: 'Times New Roman';"><br />
<span style="font-size: small;">Step 1. Create Silverlight Application</span></span></u></div><div class="MsoNormal" style="margin: 0in 0in 10pt;"><br />
In Visual Studio 2008, go File->New->Project then select Sivlerlight Application. You can name whatever name you would like to call. I will name it popFormDemo in this sample as Fig 5.<br />
<br />
<img alt="Fig 5. Create Silverlight project.jpg" border="0" height="490px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%205.%20Create%20Silverlight%20project.jpg" title="Create Silverlight project" width="685px" /><br />
Fig 5. Create Silverlight project<br />
<br />
<span style="font-family: Verdana;"><span style="font-size: small;"><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-font-family: 'Times New Roman'; mso-bidi-language: AR-SA; mso-fareast-font-family: 新細明體; mso-fareast-language: ZH-TW;">You should see the wizard window after you click OK in step 1. We will leave it in default setting as Fig 6.</span><br />
<br />
<img alt="Fig 6. Add Silverlight Application wizard.jpg" border="0" height="389px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%206.%20Add%20Silverlight%20Application%20wizard.jpg" title="Add Silverlight Application wizard" width="439px" /><br />
Fig 6. Add Silverlight Application wizard<br />
<br />
Add New Folder under PopFormDemo Project with name CusControl as Fig 7.<br />
<br />
<img alt="Fig 7. Create new folder in PopFormDemo project.jpg" border="0" height="197px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%207.%20Create%20new%20folder%20in%20PopFormDemo%20project.jpg" title="Create new folder in PopFormDemo project" width="224px" /> </span></span></div><div class="MsoNormal" style="margin: 0in 0in 10pt;">Fig 7. Create new folder in PopFormDemo project<br />
<br />
Under CusControl Folder, add New Silverlight user control with name PopForm as Fig 8.<br />
<br />
<img alt="Fig 8. Add new Silverlight User Control in CusControl folder.jpg" border="0" height="410px" src="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/Images/Fig%208.%20Add%20new%20Silverlight%20User%20Control%20in%20CusControl%20folder.jpg" title="Add new Silverlight User Control in CusControl folder" width="850px" /><br />
Fig 8. Add new Silverlight User Control in CusControl folder</div><div class="MsoNormal" style="margin: 0in 0in 10pt;">READ MORE >> <a href="http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/PopSearchFormControlinSilverlight.aspx">http://www.c-sharpcorner.com/UploadFile/MIB426/PopSearchFormControlinSilverlight08052009065841AM/PopSearchFormControlinSilverlight.aspx</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-33970256530246427262011-04-23T06:33:00.000-07:002011-04-23T06:33:55.380-07:00Use of Stopwatch Class in C#<div dir="ltr" style="text-align: left;" trbidi="on"><span class="Apple-style-span" style="font-family: verdana; font-size: x-small;"></span><br />
<div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><span style="color: black;">Using the following line a new stopwatch object will be created:</span></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><b><span style="color: #2b91af;">System.Diagnostics</span>.Stopwatch myStopWatch = <span style="color: blue;">new</span><span style="color: #2b91af;">System.Diagnostics</span>.Stopwatch();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;">The "Start" method will start the stopwatch:</span><br />
<a name='more'></a></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><b>myStopWatch.<span style="color: #2b91af;">Start</span>();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;">The "Stop" method will stop the stopwatch:</span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><b>myStopWatch.Stop();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;">To display the value of the stopwatch then use the code shown below:</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"><summary><br />
///</span><span style="color: green; font-family: Verdana;"> To get the value of Hours..</span><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"></summary></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><b>myStopWatch.<span style="color: #2b91af;">Elapsed</span>.<span style="color: #2b91af;">Hours</span>.ToString();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"><summary><br />
///</span><span style="color: green; font-family: Verdana;"> To get the value of Minutes..</span><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"></summary></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><b>myStopWatch.<span style="color: #2b91af;">Elapsed</span>.<span style="color: #2b91af;">Minutes</span>.ToString();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"><summary><br />
///</span><span style="color: green; font-family: Verdana;"> To get the value of Seconds..</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"></summary></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-family: Verdana;"><b>myStopWatch.<span style="color: #2b91af;">Elapsed</span>.<span style="color: #2b91af;">Seconds</span>.ToString();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="color: grey; font-family: Verdana;"><br />
///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"><summary><br />
///</span><span style="color: green; font-family: Verdana;"> To get the value of Milliseconds..</span><span style="color: grey; font-family: Verdana;">///</span><span style="color: green; font-family: Verdana;"> </span><span style="color: grey; font-family: Verdana;"></summary></span><span style="font-family: Verdana;"><br />
<b>MyStopWatch.<span style="color: #2b91af;">Elapsed</span>.<span style="color: #2b91af;">Milliseconds</span>.ToString();</b></span></div><div style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><br />
<span style="font-family: Verdana;"><b>Main Code :</b></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Collections.Generic;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.ComponentModel;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Data;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Drawing;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Linq;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Text;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Windows.Forms;</span><span style="color: blue; font-family: Verdana;">using</span><span style="font-family: Verdana;"> System.Data.SqlClient;</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="color: blue; font-family: Verdana;">namespace</span><span style="font-family: Verdana;"> MyBlog</span><span style="font-family: Verdana;">{<br />
<span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Form1</span> : <span style="color: #2b91af;">Form</span> {<br />
<span style="color: blue;">public</span> Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<span style="color: blue;">private</span> <span style="color: blue;">void</span> button1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<br />
{<br />
System.Diagnostics.<span style="color: #2b91af;">Stopwatch</span> myStopWatch = <span style="color: blue;">new</span>System.Diagnostics.<span style="color: #2b91af;">Stopwatch</span>();</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"> <span style="color: green;">//Start StopWatch...</span> myStopWatch.Start();</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"> <span style="color: #2b91af;">SqlConnection</span> conn = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlConnection</span>(<span style="color: #a31515;">@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\myDatabase.mdf;Integrated Security=True;User Instance=True"</span>);<br />
<span style="color: #2b91af;">SqlDataReader</span> dr;<br />
<span style="color: blue;">try</span> {<br />
conn.Open();<br />
<span style="color: #2b91af;">SqlCommand</span> cmd = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlCommand</span>(<span style="color: #a31515;">"SELECT StudName FROM Student WHERE StudId=1"</span>, conn);<br />
dr = cmd.ExecuteReader();<br />
<span style="color: blue;">while</span> (dr.Read())<br />
{<br />
<span style="color: green;">//it will display Name of Student whose Id is "1"...</span> mytxtName.Text = dr.GetValue(0).ToString();<br />
}<br />
<span style="color: green;">//Stop StopWatch...</span> myStopWatch.Stop();</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"> <span style="color: green;">//Display time which taken to load resulted data in textbox in messagebox...</span> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: #a31515;">"Time Taken : "</span> + myStopWatch.Elapsed.Hours.ToString() + <span style="color: #a31515;">" : "</span> + myStopWatch.Elapsed.Minutes.ToString() + <span style="color: #a31515;">" : "</span> + myStopWatch.Elapsed.Seconds.ToString() + <span style="color: #a31515;">" : "</span> + myStopWatch.Elapsed.Milliseconds.ToString());<br />
dr.Close();<br />
}<br />
<span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> ex)<br />
{<br />
<span style="color: #2b91af;">MessageBox</span>.Show(ex.ToString());<br />
}<br />
<span style="color: blue;">finally</span> {<br />
conn.Close();<br />
}<br />
}<br />
}<br />
}</span><br />
<span style="font-family: Verdana;"><br />
</span><br />
<span style="font-family: Verdana;">READ MORE>></span><br />
<span style="font-family: Verdana;"><a href="http://www.c-sharpcorner.com/UploadFile/9f4ff8/6898/">http://www.c-sharpcorner.com/UploadFile/9f4ff8/6898/</a></span></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-84524584604183413812011-04-18T21:58:00.000-07:002011-04-18T21:58:14.186-07:00Resource Management In Silverligt 3<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">The files required for any Application to run other than project related files are called resources. It can be a text file or image file or any other file. In this article, we will be seeing how images can be accessed in various ways in a Silverlight application.</span><br />
<a name='more'></a><br />
<br />
<b>Types of Resource Management</b><br />
<br />
There are 3 ways we can manage resources such as: <br />
<ol><span style="font-size: x-small;">
<li><div align="left"><span style="font-family: Verdana; font-size: small;">Add Image as Resource</span></div></li>
<li><div align="left"><span style="font-family: Verdana; font-size: small;">Add Image as Content </span></div></li>
<li><div align="left"><span style="font-family: Verdana; font-size: small;">Add Image as Resource in an external assembly</span></div></li>
</span></ol><div align="left"><span style="font-family: Verdana;"><b>Create a Silverlight Project</b><br />
<img alt="image1.gif" border="0" height="413" src="http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/Images/image1.gif" width="562" /><br />
<br />
Figure 1.1 Creating Silverlight Project<br />
<br />
<b>Designing the Application</b><br />
<br />
For our sample application let's put 3 Image Control, 3 Buttons and 3 TextBlocks to display the type of resource. Use blend to design the application.<br />
<br />
<img alt="image2.gif" border="0" height="219" src="http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/Images/image2.gif" width="625" /><br />
<br />
Figure 1.2 Designing the Application<br />
<br />
<b>Add Images to the Project</b><br />
<br />
In SampleSilverlightApplication project add a folder called images and two images are added. As you can see the images we are going to change the Build Action of the images. We will change the Build Action for firefox.png to Resource and IE.png to Content.<br />
<br />
<img alt="image3.gif" border="0" height="310" src="http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/Images/image3.gif" width="244" /><br />
<br />
Figure 1.3 Adding images to the project<br />
<br />
<img alt="image4.gif" border="0" height="190" src="http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/Images/image4.gif" width="550" /><br />
<br />
Figure 1.4 Changing the Build Action of the Images.<br />
<br />
<b>Adding another Project</b><br />
<br />
To use Image from another assembly we need to add project to the solution and we will add the Image to it. Then we will add the project refference to our main project (SampleSilverlightApplication).<br />
<br />
<img alt="image5.gif" border="0" height="387" src="http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/Images/image5.gif" width="485" /><br />
<br />
Figure 1.5 Adding another project to the Solution and adding Images to the added project<br />
<br />
We have just added One Silverlight Class Library to the Solution and added the folder images and ofcourse we added chrome.png. The SecondApplicaion reference is added to the SampleSilverlightApplication.<br />
<br />
READ MORE>></span></div><div align="left"><a href="http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/ResourceManagementInSilverlight3.aspx">http://www.c-sharpcorner.com/UploadFile/dpatra/ResourceManagementInSilverlight307012009001815AM/ResourceManagementInSilverlight3.aspx</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-24862742626521515472011-04-17T21:17:00.000-07:002011-04-17T21:17:59.337-07:00Splash Screen in Silverlight 3 Application<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">If a Silverlight application is small, it will be downloaded quickly and appear in the browser. If a Silverlight application is large, it may take a few seconds to download. As long as your application takes longer than 500 milliseconds to download, Silverlight will show an animated splash screen.</span><br />
<a name='more'></a><br />
Splash Screens can be used for the following purposes: <br />
<ol><li>To show the Progress of downloading the xap file. (By Default) </li>
<li>Copyright Information </li>
<li>Custom Animation.</li>
</ol><b>Crating Silverlight Project</b><br />
<br />
Fire up Visual Studio 2008 and create a Silverlight Application. Name it as SplashScreenInSL3.<br />
<br />
<img alt="image1.gif" border="0" height="421" src="http://www.c-sharpcorner.com/UploadFile/dpatra/SplashScreenInSilverlight3Application07282009135404PM/Images/image1.gif" width="624" /><br />
<br />
The built in Splash Screen is not that exciting. It simply displays a ring of blinking circles and the percentage of the application that's been downloaded so far.<br />
<br />
If you don't like the stock splash screen, you can easily create your own. Essentially, a custom splash screen is a XAML file with the graphical content you want to display, and a dash of JavaScript code that updates the splash screen as the application is downloaded.<br />
<br />
Add a new XAML file to your ASP.NET website (not the Silverlight project). <br />
<br />
Choose the Silverlight JScript page template, enter a name, and click Add. This XAML file will hold the markup for your splash screen.<br />
<br />
<img alt="image2.gif" border="0" height="378" src="http://www.c-sharpcorner.com/UploadFile/dpatra/SplashScreenInSilverlight3Application07282009135404PM/Images/image2.gif" width="627" /><br />
<br />
Add the following xaml code into it.<br />
<br />
<img alt="image2.1.gif" border="0" height="214" src="http://www.c-sharpcorner.com/UploadFile/dpatra/SplashScreenInSilverlight3Application07282009135404PM/Images/image2.1.gif" width="235" /><br />
<br />
<span style="color: blue;"><</span><span style="color: #a31515;">Grid</span><span style="color: blue;"> </span><span style="color: red;">xmlns</span><span style="color: blue;">=</span><span>"<a href="http://schemas.microsoft.com/client/2007"><span style="color: blue;">http://schemas.microsoft.com/client/2007</span></a>"</span><span style="color: blue;"> </span><span style="color: red;">xmlns:x</span><span style="color: blue;">=</span><span>"<span style="color: blue;">http://schemas.microsoft.com/winfx/2006/xaml</span>"<span style="color: blue;">></span></span><span style="color: blue;"> <</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span><span>"<span style="color: blue;">Center</span>"<span style="color: blue;">></span></span><span style="color: blue;"> <</span><span style="color: #a31515;">Grid</span><span style="color: blue;">><br />
<</span><span style="color: #a31515;">Rectangle</span><span style="color: blue;"> </span><span style="color: red;">x:Name</span><span style="color: blue;">=</span><span>"<span style="color: blue;">progressBarBackground</span>"<span style="color: blue;"> </span><span style="color: red;">Fill</span><span style="color: blue;">=</span>"<span style="color: blue;">White</span>"<span style="color: blue;"> </span><span style="color: red;">Stroke</span><span style="color: blue;">=</span>"<span style="color: blue;">Black</span>"<span style="color: blue;"> </span><span style="color: red;">StrokeThickness</span><span style="color: blue;">=</span>"<span style="color: blue;">1</span>"<span style="color: blue;"> </span><span style="color: red;">Height</span><span style="color: blue;">=</span>"<span style="color: blue;">30</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;">></</span><span style="color: #a31515;">Rectangle</span><span style="color: blue;">></span></span><span style="color: blue;"> <</span><span style="color: #a31515;">Rectangle</span><span style="color: blue;"> </span><span style="color: red;">x:Name</span><span style="color: blue;">=</span><span>"<span style="color: blue;">progressBar</span>"<span style="color: blue;"> </span><span style="color: red;">Fill</span><span style="color: blue;">=</span>"<span style="color: blue;">Yellow</span>"<span style="color: blue;"> </span><span style="color: red;">Height</span><span style="color: blue;">=</span>"<span style="color: blue;">28</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">0</span>"<span style="color: blue;">></</span><span style="color: #a31515;">Rectangle</span><span style="color: blue;">></span></span><span style="color: blue;"> </</span><span style="color: #a31515;">Grid</span><span style="color: blue;">><br />
<</span><span style="color: #a31515;">TextBlock</span><span style="color: blue;"> </span><span style="color: red;">x:Name</span><span style="color: blue;">=</span><span>"<span style="color: blue;">progressText</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Text</span><span style="color: blue;">=</span>"<span style="color: blue;">0% downloaded ...</span>"<span style="color: blue;">></</span><span style="color: #a31515;">TextBlock</span><span style="color: blue;">></span></span><span style="color: blue;"> </</span><span style="color: #a31515;">StackPanel</span><span style="color: blue;">></span> <br />
<span style="color: blue; font-family: Calibri;"></</span><span style="color: #a31515; font-family: Calibri;">Grid</span><span style="color: blue; font-family: Calibri;">></span> <br />
Next, you need to add a JavaScript function to your ASPX entry page or ASP.NET test page. (If you plan on using both, place the JavaScript function in a separate file and then link to it in both files using the source attribute of the script block.) The JavaScript code can look up named elements on the page using the sender.findName() method, and manipulate their properties. It can also determine the current progress using the eventArgs.progress property. In this example, the event handling code simply updates the text and widens the progress bar based on the current progress percentage:<br />
<br />
<span style="color: blue;"><</span><span style="color: #a31515;">script</span><span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span> <span style="color: blue;">function</span> onSourceDownloadProgressChanged(sender, eventArgs) {<br />
sender.findName(<span style="color: #a31515;">"progressText"</span>).Text = Math.round((eventArgs.progress * 100)) + <span style="color: #a31515;">"% downloaded ..."</span>;<br />
sender.findName(<span style="color: #a31515;">"progressBar"</span>).Width = eventArgs.progress * sender.findName(<span style="color: #a31515;">"progressBarBackground"</span>).Width;<br />
}<br />
<span style="color: blue;"></</span><span style="color: #a31515;">script</span><span style="color: blue;">></span></span> <br />
To use this splash screen, you need to add the splashscreensource parameter to identify your XAML splash screen and the onsourcedownloadprogresschanged parameter to hook up your JavaScript event handler. If you want to react when the download is finished, you can hook up a different JavaScript event handler using the onsourcedownloadcomplete parameter.<br />
<br />
<span style="color: blue;"><</span><span style="color: #a31515;">object</span><span> <span style="color: red;">data</span><span style="color: blue;">="data:application/x-silverlight-2,"</span> <span style="color: red;">type</span><span style="color: blue;">="application/x-silverlight-2"</span> <span style="color: red;">width</span><span style="color: blue;">="100%"</span> <span style="color: red;">height</span><span style="color: blue;">="100%"></span></span><span style="color: blue;"><</span><span style="color: #a31515;">param</span><span> <span style="color: red;">name</span><span style="color: blue;">="source"</span> <span style="color: red;">value</span><span style="color: blue;">="ClientBin/SplashScreenInSL3.xap"/></span> <span style="color: blue;"><</span><span style="color: #a31515;">param</span> <span style="color: red;">name</span><span style="color: blue;">="onError"</span> <span style="color: red;">value</span><span style="color: blue;">="onSilverlightError"</span> <span style="color: blue;">/></span> <span style="color: blue;"><</span><span style="color: #a31515;">param</span> <span style="color: red;">name</span><span style="color: blue;">="background"</span> <span style="color: red;">value</span><span style="color: blue;">="white"</span> <span style="color: blue;">/></span> <span style="color: blue;"><</span><span style="color: #a31515;">param</span> <span style="color: red;">name</span><span style="color: blue;">="minRuntimeVersion"</span> <span style="color: red;">value</span><span style="color: blue;">="3.0.40624.0"</span> <span style="color: blue;">/></span> <span style="color: blue;"><</span><span style="color: #a31515;">param</span> <span style="color: red;">name</span><span style="color: blue;">="autoUpgrade"</span> <span style="color: red;">value</span><span style="color: blue;">="true"</span> <span style="color: blue;">/></span> <span style="background: yellow; color: blue;"><</span><span style="background: yellow; color: #a31515;">param</span><span style="background: yellow;"> <span style="color: red;">name</span><span style="color: blue;">="splashscreensource"</span> <span style="color: red;">value</span><span style="color: blue;">="MySplashScreen.xaml"</span> <span style="color: blue;">/></span></span></span><span style="background: yellow;"> <span style="color: blue;"><</span><span style="color: #a31515;">param</span> <span style="color: red;">name</span><span style="color: blue;">="onsourcedownloadprogresschanged"</span> <span style="color: red;">value</span><span style="color: blue;">="onSourceDownloadProgressChanged"</span> <span style="color: blue;">/></span></span><span> <span style="color: blue;"><</span><span style="color: #a31515;">a</span> <span style="color: red;">href</span><span style="color: blue;">="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">text-decoration</span>:<span style="color: blue;">none"></span> <span style="color: blue;"><</span><span style="color: #a31515;">img</span> <span style="color: red;">src</span><span style="color: blue;">="http://go.microsoft.com/fwlink/?LinkId=108181"</span> <span style="color: red;">alt</span><span style="color: blue;">="Get Microsoft Silverlight"</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">border-style</span>:<span style="color: blue;">none"/></span> <span style="color: blue;"></</span><span style="color: #a31515;">a</span><span style="color: blue;">></span> <span style="color: blue;"></</span><span style="color: #a31515;">object</span><span style="color: blue;">></span></span> <br />
READ MORE >><br />
<a href="http://www.c-sharpcorner.com/UploadFile/dpatra/SplashScreenInSilverlight3Application07282009135404PM/SplashScreenInSilverlight3Application.aspx">http://www.c-sharpcorner.com/UploadFile/dpatra/SplashScreenInSilverlight3Application07282009135404PM/SplashScreenInSilverlight3Application.aspx</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-70925298242538976782011-04-14T21:42:00.000-07:002011-04-14T21:44:06.411-07:00InitParams in Silverlight<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">If you are developing a Silverlight Application, and you need to pass some parameters inside – for example a key and value pair then we can pass the key value pair from the aspx page itself. We will see how we can do this in Silverlight.</span><br />
<a name='more'></a><br />
<br />
<span style="font-family: Verdana;"><b>Create a Silverlight Project</b></span><br />
<span style="font-family: Verdana;"><img alt="image1.gif" border="0" height="476" src="http://www.c-sharpcorner.com/UploadFile/dpatra/InitParamsInSilverlight06302009024633AM/Images/image1.gif" width="653" /><br />
<br />
Figure 1.1 Creating Silverlight Project<br />
<br />
<b>Adding parameters</b><br />
<br />
Open the "InitializingParametersTestPage.aspx" and find the tag <span style="font-family: Verdana; line-height: 115%;"><span style="font-size: x-small;">tag </span></span><span style="color: blue; font-family: Verdana; font-size: 10pt; line-height: 115%;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt; line-height: 115%;">asp</span><span style="color: blue; font-family: Verdana; font-size: 10pt; line-height: 115%;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt; line-height: 115%;">Silverlight</span><span style="font-family: Verdana; font-size: 10pt; line-height: 115%;"> </span><span style="font-size: x-small;">add an attribute </span><span style="color: red; font-family: Verdana; font-size: 10pt; line-height: 115%;">InitParameters</span></span><span style="font-size: x-small;"><br />
<span style="font-family: Verdana;">Enter the following code to the tag</span></span><span style="font-family: Verdana;"><span style="color: red; font-size: 10pt; line-height: 115%;">InitParameters</span><span style="color: blue; font-size: 10pt; line-height: 115%;">="Key1=Value1,Key2=Value2"</span></span><span style="font-size: x-small;"><br />
<br />
<span style="font-family: Verdana;"><b>Defining the Parameters</b><br />
<br />
In App.xaml.cs add an object of IDictionary<string,string> as follows</span></span><span style="color: blue; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana;">public</span></span><span style="font-family: Verdana;"><span style="font-size: 10pt; line-height: 115%;"> <span style="color: #2b91af;">IDictionary</span><<span style="color: blue;">string</span>, <span style="color: blue;">string</span>> AppParams;<br />
In Application_Startup event initialize the parameters as follows</span><span style="color: blue; font-size: 10pt;">private</span></span><span style="font-size: 10pt;"><span style="font-family: Verdana;"> <span style="color: blue;">void</span> Application_Startup(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">StartupEventArgs</span> e)<br />
{<br />
AppParams = e.InitParams;<br />
<span style="color: blue;">this</span>.RootVisual = <span style="color: blue;">new</span> <span style="color: #2b91af;">Page</span>();</span></span><span style="font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana;"> }</span></span><span style="font-size: x-small;"><br />
<span style="font-family: Verdana;"><b>Using Parameters</b><br />
<br />
In Page.xaml add ListBoxes to show the parameter values<br />
Xaml Code</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">UserControl</span><span style="color: red; font-size: 10pt;"> x</span><span style="color: blue; font-size: 10pt;">:</span><span style="color: red; font-size: 10pt;">Class</span></span><span style="color: blue; font-size: 10pt;"><span style="font-family: Verdana;">="InitializingParameters.Page"</span></span><span style="font-size: 10pt;"><span style="font-family: Verdana;"> <span style="color: red;"> xmlns</span><span style="color: blue;">="<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>"</span> <br />
<span style="color: red;"> xmlns</span><span style="color: blue;">:</span><span style="color: red;">x</span><span style="color: blue;">="<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>"</span> <br />
<span style="color: red;"> Width</span><span style="color: blue;">="400"</span><span style="color: red;"> Height</span></span><span style="color: blue;"><span style="font-family: Verdana;">="300"></span></span></span><span style="font-family: Verdana;"><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">Grid</span><span style="color: red; font-size: 10pt;"> x</span><span style="color: blue; font-size: 10pt;">:</span><span style="color: red; font-size: 10pt;">Name</span><span style="color: blue; font-size: 10pt;">="LayoutRoot"</span><span style="color: red; font-size: 10pt;"> Background</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">="#FFB7C2E5"></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">Grid.ColumnDefinitions</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">ColumnDefinition</span><span style="color: red; font-size: 10pt;"> Width</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">="0.472*"/></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">ColumnDefinition</span><span style="color: red; font-size: 10pt;"> Width</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">="0.025*"/></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">ColumnDefinition</span><span style="color: red; font-size: 10pt;"> Width</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">="0.502*"/></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"></</span><span style="color: #a31515; font-size: 10pt;">Grid.ColumnDefinitions</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">ListBox</span><span style="color: red; font-size: 10pt;"> x</span><span style="color: blue; font-size: 10pt;">:</span><span style="color: red; font-size: 10pt;">Name</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">="myKeysList"/></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"><</span><span style="color: #a31515; font-size: 10pt;">ListBox</span><span style="color: red; font-size: 10pt;"> x</span><span style="color: blue; font-size: 10pt;">:</span><span style="color: red; font-size: 10pt;">Name</span><span style="color: blue; font-size: 10pt;">="myValuesList"</span><span style="color: red; font-size: 10pt;"> Grid.Column</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">="2"/></span><span style="color: #a31515; font-size: 10pt;"> </span><span style="color: blue; font-size: 10pt;"></</span><span style="color: #a31515; font-size: 10pt;">Grid</span></span><span style="font-family: Verdana;"><span style="color: blue; font-size: 10pt;">></span><span style="color: blue; font-size: 10pt; line-height: 115%;"></</span><span style="color: #a31515; font-size: 10pt; line-height: 115%;">UserControl</span></span><span style="color: blue; font-size: 10pt; line-height: 115%;"><span style="font-family: Verdana;">></span></span><span style="font-size: x-small;"><br />
<span style="font-family: Verdana;">In code behind of the Page.xaml.cs add the following code to bind the parameters</span></span><span style="color: blue; font-size: 10pt;"><span style="font-family: Verdana;">namespace</span></span><span style="font-size: 10pt;"><span style="font-family: Verdana;"> InitializingParameters<br />
{<br />
<span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Page</span> : </span><span style="font-family: Verdana;"><span style="color: #2b91af;">UserControl</span> {<br />
<span style="color: blue;">public</span> Page()<br />
{<br />
InitializeComponent();<br />
<span style="color: #2b91af;">App</span> myApp = <span style="color: #2b91af;">App</span>.Current <span style="color: blue;">as</span> <span style="color: #2b91af;">App</span>;</span></span> <br />
<br />
<br />
<br />
<div align="left" class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><span style="font-family: Verdana;"><span style="font-size: 10pt;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> item <span style="color: blue;">in</span> myApp.AppParams.Keys)<br />
{<br />
myKeysList.Items.Add(item);<br />
}<br />
<span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> item1 <span style="color: blue;">in</span> myApp.AppParams.Values)<br />
{<br />
myValuesList.Items.Add(item1);<br />
}<br />
}<br />
}</span><span style="font-size: 10pt; line-height: 115%;">}</span></span><span style="font-family: Verdana; font-size: x-small;"><br />
READ MORE>></span></div><div align="left" class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><a href="http://www.c-sharpcorner.com/UploadFile/dpatra/InitParamsInSilverlight06302009024633AM/InitParamsInSilverlight.aspx">http://www.c-sharpcorner.com/UploadFile/dpatra/InitParamsInSilverlight06302009024633AM/InitParamsInSilverlight.aspx</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-83686461184688692022011-04-11T21:43:00.000-07:002011-04-11T21:43:14.499-07:00Scene Order (Layer Order) in XAML Silverlight<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">XAML is fully based on composition of object scenes. Every XAML page has a parent/top most container (like UserControl/Canvas/Page etc) and it may have zero or more children elements (like Grid/Rectange/Ellipse etc). Look at the example below:</span> <br />
<a name='more'></a><br />
<br />
<img alt="LayerSilver1.gif" border="0" height="403" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6706/Images/LayerSilver1.gif" width="623" /><br />
<br />
In the above screenshot, use three elements named LayoutRoot, LayoutRoot1 and Rec1. LayoutRoot (white background) is lower most (beneath); look at the code above and examine the order of elements:<br />
<ol><li><span style="font-family: Verdana;">LayoutRoot (Grid)</span> </li>
<li><span style="font-family: Verdana;">LayoutRoot1 (Grid)</span> </li>
<li><span style="font-family: Verdana;">Rec1 (Rectangle)</span></li>
</ol><br />
<span style="font-family: Verdana;">Please note that, usually we write code in a top to bottom approach in general, so the order of shapes (elements) also varies on this. If you wish to bring "LayoutRoot (White Grid)" to the front then the order of elements will also be rearranged automatically. Look at the screenshot below:<br />
<br />
<img alt="LayerSilver2.gif" border="0" height="404" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6706/Images/LayerSilver2.gif" width="624" /><br />
</span><br />
<span style="font-family: Verdana;">READ MORE>></span><br />
<span style="font-family: Verdana;"><a href="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6706/">http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6706/</a></span></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-21955582255155763802011-04-10T21:47:00.000-07:002011-04-10T21:47:03.731-07:00Plane Projection in Silverlight 3<div dir="ltr" style="text-align: left;" trbidi="on">In this article we will see Projection in Silverlight, which describe how to transform an object in 3-D space using perspective transforms. In this article we will use Plane Projection, which represents a perspective transform (a 3-D-like effect) on an object.<br />
<a name='more'></a><br />
<span style="font-size: x-small;"><span style="font-size: small;"><b>Creating Silverlight Project</b><br />
Fire up Visual Studio 2008 and create a Silverlight Application. Name it as PlaneProjectionInSL3.<br />
</span><img alt="image1.gif" border="0" height="404" src="http://www.c-sharpcorner.com/UploadFile/dpatra/PlaneProjectionInSilverlight308022009022816AM/Images/image1.gif" width="599" /><br />
<br />
<span style="font-size: small;">Open the solution in Expression Blend 3 to design the application.<br />
<br />
Our basic aim of the sample is to rotate an image in 3 directions that is X, Y and Z plane. So we need three TextBlocks and three Slider Controls and an Image Control.<br />
<br />
The design will look something similar to the following:<br />
</span><img alt="image2.gif" border="0" height="420" src="http://www.c-sharpcorner.com/UploadFile/dpatra/PlaneProjectionInSilverlight308022009022816AM/Images/image2.gif" width="427" /><br />
<br />
<span style="font-size: small;">If you look into the Objects and Timeline Pane you will find the following controls are used.<br />
</span><img alt="image3.gif" border="0" height="386" src="http://www.c-sharpcorner.com/UploadFile/dpatra/PlaneProjectionInSilverlight308022009022816AM/Images/image3.gif" width="237" /><br />
</span><span style="font-size: small;">Now go back to Visual Studio 2008 environment.<br />
<br />
Here is the Xaml code for your reference:</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">LayoutRoot</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">BorderThickness</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">5</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">120,40</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">400</span>"<span style="color: blue;"> </span><span style="color: red;">Height</span><span style="color: blue;">=</span>"<span style="color: blue;">400</span>"<span style="color: blue;"> </span><span style="color: red;">CornerRadius</span><span style="color: blue;">=</span>"<span style="color: blue;">5</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border.BorderBrush</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RadialGradientBrush</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">GradientStop</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Color</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Black</span>"<span style="color: blue;"> </span><span style="color: red;">Offset</span><span style="color: blue;">=</span>"<span style="color: blue;">0</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">GradientStop</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Color</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">White</span>"<span style="color: blue;"> </span><span style="color: red;">Offset</span><span style="color: blue;">=</span>"<span style="color: blue;">1</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RadialGradientBrush</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border.BorderBrush</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid.ColumnDefinitions</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ColumnDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Width</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.174*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ColumnDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Width</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.633*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ColumnDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Width</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.192*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid.ColumnDefinitions</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid.RowDefinitions</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RowDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.005*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RowDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.308*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RowDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.556*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RowDefinition</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.131*</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid.RowDefinitions</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Grid.Column</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">1</span>"<span style="color: blue;"> </span><span style="color: red;">Grid.Row</span><span style="color: blue;">=</span>"<span style="color: blue;">1</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">0,0,0,25</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">20</span>"<span style="color: blue;"> </span><span style="color: red;">Orientation</span><span style="color: blue;">=</span>"<span style="color: blue;">Horizontal</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">246</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Rotation X</span>"<span style="color: blue;"> </span><span style="color: red;">TextWrapping</span><span style="color: blue;">=</span>"<span style="color: blue;">Wrap</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Slider</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">SliderX</span>"<span style="color: blue;"> </span><span style="color: red;">Maximum</span><span style="color: blue;">=</span>"<span style="color: blue;">360</span>"<span style="color: blue;"> </span><span style="color: red;">Minimum</span><span style="color: blue;">=</span>"<span style="color: blue;">-360</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">5,0,0,0</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;">/></span></span> <br />
<div class="MsoNormal"><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span> </div><div class="MsoNormal"><span style="color: blue; font-family: Verdana; font-size: 10pt;"> <</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">20</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">246</span>"<span style="color: blue;"> </span><span style="color: red;">Orientation</span><span style="color: blue;">=</span>"<span style="color: blue;">Horizontal</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Rotation Y</span>"<span style="color: blue;"> </span><span style="color: red;">TextWrapping</span><span style="color: blue;">=</span>"<span style="color: blue;">Wrap</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Slider</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">SliderY</span>"<span style="color: blue;"> </span><span style="color: red;">Maximum</span><span style="color: blue;">=</span>"<span style="color: blue;">360</span>"<span style="color: blue;"> </span><span style="color: red;">Minimum</span><span style="color: blue;">=</span>"<span style="color: blue;">-360</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">5,0,0,0</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">20</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">246</span>"<span style="color: blue;"> </span><span style="color: red;">Orientation</span><span style="color: blue;">=</span>"<span style="color: blue;">Horizontal</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Rotation Z</span>"<span style="color: blue;"> </span><span style="color: red;">TextWrapping</span><span style="color: blue;">=</span>"<span style="color: blue;">Wrap</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Slider</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">SliderZ</span>"<span style="color: blue;"> </span><span style="color: red;">Maximum</span><span style="color: blue;">=</span>"<span style="color: blue;">360</span>"<span style="color: blue;"> </span><span style="color: red;">Minimum</span><span style="color: blue;">=</span>"<span style="color: blue;">-360</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">5,0,0,0</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">21</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">0,10,0,0</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Button</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">btnReset</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">75</span>"<span style="color: blue;"> </span><span style="color: red;">Content</span><span style="color: blue;">=</span>"<span style="color: blue;">Reset</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Grid.Column</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">1</span>"<span style="color: blue;"> </span><span style="color: red;">Grid.Row</span><span style="color: blue;">=</span>"<span style="color: blue;">2</span>"<span style="color: blue;"> </span><span style="color: red;">BorderBrush</span><span style="color: blue;">=</span>"<span style="color: blue;">Black</span>"<span style="color: blue;"> </span><span style="color: red;">BorderThickness</span><span style="color: blue;">=</span>"<span style="color: blue;">2</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Image</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Source</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Images/iMac OSX.png</span>"<span style="color: blue;"> </span><span style="color: red;">Stretch</span><span style="color: blue;">=</span>"<span style="color: blue;">UniformToFill</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><br />
<br />
Now the Border Control which contains the Image; we need to add Projection and then Plane Projection. The xaml will look as follows:<br />
<span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Grid.Column</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">1</span>"<span style="color: blue;"> </span><span style="color: red;">Grid.Row</span><span style="color: blue;">=</span>"<span style="color: blue;">2</span>"<span style="color: blue;"> </span><span style="color: red;">BorderBrush</span><span style="color: blue;">=</span>"<span style="color: blue;">Black</span>"<span style="color: blue;"> </span><span style="color: red;">BorderThickness</span><span style="color: blue;">=</span>"<span style="color: blue;">2</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border.Projection</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">PlaneProjection</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Projection</span>"</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</span><span style="color: red; font-family: Verdana; font-size: 10pt;">CenterOfRotationX</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.5</span>"</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</span><span style="color: red; font-family: Verdana; font-size: 10pt;">CenterOfRotationY</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.5</span>"</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</span><span style="color: red; font-family: Verdana; font-size: 10pt;">CenterOfRotationZ</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">0.5</span>"<span style="color: blue;"> /></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border.Projection</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Image</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Source</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Images/iMac OSX.png</span>"<span style="color: blue;"> </span><span style="color: red;">Stretch</span><span style="color: blue;">=</span>"<span style="color: blue;">UniformToFill</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Border</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><br />
<br />
<span style="font-size: x-small;"><span style="font-size: small;">Now we will bind the Projection with the respective Slider Controls.<br />
</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">20</span>"<span style="color: blue;"> </span><span style="color: red;">Orientation</span><span style="color: blue;">=</span>"<span style="color: blue;">Horizontal</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">246</span>"<span style="color: blue;">></span></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Rotation X</span>"<span style="color: blue;"> </span><span style="color: red;">TextWrapping</span><span style="color: blue;">=</span>"<span style="color: blue;">Wrap</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Slider</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">SliderX</span>"<span style="color: blue;"> </span><span style="color: red;">Maximum</span><span style="color: blue;">=</span>"<span style="color: blue;">360</span>"<span style="color: blue;"> </span><span style="color: red;">Minimum</span><span style="color: blue;">=</span>"<span style="color: blue;">-360</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">5,0,0,0</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;"> </span><span style="color: red;">Value</span><span style="color: blue;">=</span>"<span style="color: blue;">{Binding ElementName=Projection, Mode=TwoWay, Path=RotationX}</span>"<span style="color: blue;"> /></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">20</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">246</span>"<span style="color: blue;"> </span><span style="color: red;">Orientation</span><span style="color: blue;">=</span>"<span style="color: blue;">Horizontal</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Rotation Y</span>"<span style="color: blue;"> </span><span style="color: red;">TextWrapping</span><span style="color: blue;">=</span>"<span style="color: blue;">Wrap</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Slider</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">SliderY</span>"<span style="color: blue;"> </span><span style="color: red;">Maximum</span><span style="color: blue;">=</span>"<span style="color: blue;">360</span>"<span style="color: blue;"> </span><span style="color: red;">Minimum</span><span style="color: blue;">=</span>"<span style="color: blue;">-360</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">5,0,0,0</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;"> </span><span style="color: red;">Value</span><span style="color: blue;">=</span>"<span style="color: blue;">{Binding ElementName=Projection, Mode=TwoWay, Path=RotationY}</span>"<span style="color: blue;"> /></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">20</span>"<span style="color: blue;"> </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">VerticalAlignment</span><span style="color: blue;">=</span>"<span style="color: blue;">Center</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">246</span>"<span style="color: blue;"> </span><span style="color: red;">Orientation</span><span style="color: blue;">=</span>"<span style="color: blue;">Horizontal</span>"<span style="color: blue;">></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">Rotation Z</span>"<span style="color: blue;"> </span><span style="color: red;">TextWrapping</span><span style="color: blue;">=</span>"<span style="color: blue;">Wrap</span>"<span style="color: blue;">/></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Slider</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"> </span><span style="color: red; font-family: Verdana; font-size: 10pt;">x:Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">=</span><span style="font-family: Verdana; font-size: 10pt;">"<span style="color: blue;">SliderZ</span>"<span style="color: blue;"> </span><span style="color: red;">Maximum</span><span style="color: blue;">=</span>"<span style="color: blue;">360</span>"<span style="color: blue;"> </span><span style="color: red;">Minimum</span><span style="color: blue;">=</span>"<span style="color: blue;">-360</span>"<span style="color: blue;"> </span><span style="color: red;">Margin</span><span style="color: blue;">=</span>"<span style="color: blue;">5,0,0,0</span>"<span style="color: blue;"> </span><span style="color: red;">Width</span><span style="color: blue;">=</span>"<span style="color: blue;">200</span>"<span style="color: blue;"> </span><span style="color: red;">Value</span><span style="color: blue;">=</span>"<span style="color: blue;">{Binding ElementName=Projection, Mode=TwoWay, Path=RotationZ}</span>"<span style="color: blue;"> /></span></span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StackPanel</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><br />
<br />
As we have added a Button to reset the Rotations. Add the following code to reset the rotation:<br />
Now our application is ready to go. Press F5 to run the application.</div><div class="MsoNormal">READ MORE>></div><div class="MsoNormal"><a href="http://www.c-sharpcorner.com/UploadFile/dpatra/PlaneProjectionInSilverlight308022009022816AM/PlaneProjectionInSilverlight3.aspx">http://www.c-sharpcorner.com/UploadFile/dpatra/PlaneProjectionInSilverlight308022009022816AM/PlaneProjectionInSilverlight3.aspx</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-59211878294670424442011-04-08T03:26:00.000-07:002011-04-08T03:26:46.615-07:00File Uplalod from Silver Light application to server location using WCF<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">This article will explain, How to upload a <b>file</b> from <b>SilverLight client</b> to server location using <b>WCF.</b><br />
To achieve above task, follow the below steps. Assume, that Reader has a basic concept of </span><br />
<a name='more'></a><br />
<ol><li><div align="left">WCF </div></li>
<li><div align="left">Silver Light </div></li>
<li><div align="left">Cross Domain Issue </div></li>
<li><div align="left">Hosting of WCF Service </div></li>
</ol><div align="left"><b>Pictorial representation of output <br />
<br />
<img alt="image1.gif" border="0" height="337" src="http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/fileuploadsilverlightwcf07142009104020AM/Images/image1.gif" width="433" /><br />
<br />
<img alt="image2.gif" border="0" height="412" src="http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/fileuploadsilverlightwcf07142009104020AM/Images/image2.gif" width="563" /><br />
<br />
<img alt="image3.gif" border="0" height="310" src="http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/fileuploadsilverlightwcf07142009104020AM/Images/image3.gif" width="551" /></b><span style="font-family: Verdana;"><br />
<b>Follow the Steps below</b> </span><span style="font-family: Verdana;"><br />
<br />
<b>Step 1:</b><br />
<br />
<b>Create and Host the WCF Service.</b><br />
<br />
<b>a.</b> Create the Contract. This got only one method, which is taking as input a file to upload.<br />
<br />
<b>IService1.svc</b><br />
<span style="color: blue;"><b><br />
</b>using</span> System;<br />
<span style="color: blue;">using</span> System.Collections.Generic;<br />
<span style="color: blue;">using</span> System.Linq;<br />
<span style="color: blue;">using</span> System.Runtime.Serialization;<br />
<span style="color: blue;">using</span> System.Text;<br />
<span style="color: blue;">namespace</span> FileUploadService <br />
{<br />
[<span style="color: #2b91af;">ServiceContract</span>]<br />
<span style="color: blue;">public</span> <span style="color: blue;">interface</span> <span style="color: #2b91af;">IService1 </span> { </span></div><div align="left" class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"></div><div align="left"> </div><div align="left"> [<span style="color: #2b91af;">OperationContract</span>]<br />
<span style="color: blue;">void</span> SaveFile(<span style="color: #2b91af;">UploadFile</span> UploadFile);<br />
}<br />
<span style="line-height: 115%;">}</span><br />
<br />
<b>b</b>. Create the Data Contract. This is going to contain the information about the uploaded file. You could either put this <b>UploadFile</b> Data Contract in same file with contract or in separate file.<br />
<br />
[<span style="color: #2b91af;">DataContract</span>]<br />
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">UploadFile</span> {<br />
[<span style="color: #2b91af;">DataMember</span>]<br />
<span style="color: blue;">public</span> <span style="color: blue;">string</span> FileName; </div><div align="left" class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"> [<span style="color: #2b91af;">DataMember</span>]<br />
<span style="color: blue;">public</span> <span style="color: blue;">byte</span>[] File;<br />
<span style="line-height: 115%;"> }</span><br />
<br />
<b>c.</b> Implement the Service. We are simply creating instance of<b> FileStream</b> in create mode and writing the stream into that.<br />
<br />
READ MORE>></div><div align="left" class="MsoNormal" style="line-height: normal; margin-bottom: 0pt;"><a href="http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/fileuploadsilverlightwcf07142009104020AM/fileuploadsilverlightwcf.aspx">http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/fileuploadsilverlightwcf07142009104020AM/fileuploadsilverlightwcf.aspx</a></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-58859053442399515242011-04-07T21:49:00.000-07:002011-04-07T21:49:40.028-07:00Hello Program in Silverlight using Expression Blend & Visual Studio<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">Install Expression Studio (it includes Blend, Encoder, Design, Web applications) for Visual Studio so that we can start developing Silverlight by using either Visual Studio or Expression Blend. Finally, what we have here is, Expression Blend adds the features to existing Visual Studio.</span><span style="font-family: Verdana;"><b>Creating "Hello" Program using Expression Blend</b><br />
<br />
Let's start Expression Blend; you will get the following splash screen at first.<br />
<br />
<img alt="Blend1.gif" border="0" height="465" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6618/Images/Blend1.gif" width="303" /><br />
<br />
This screen loads all necessarily program files to memory for building Silverlight Application. After a couple of seconds, you will get the following screen.<br />
<br />
<img alt="Blend2.gif" border="0" height="373" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6618/Images/Blend2.gif" width="624" /><br />
<br />
In this screenshot, look at the items in the red circle. <br />
<br />
<b>Projects</b><br />
<br />
This tab lets us open any recently used projects from a list, create a new project or open any existing projects. <br />
<br />
<b>Help</b><br />
<br />
This tab lets us open the User Guide by visiting online tutorials or web communities. <br />
<br />
<b>Samples</b><br />
<br />
This tab provides sample projects developed by Expression Blend development team from Microsoft or somebody else. <br />
<br />
Now, let's click on the "New Project" option; you will get the following screen.<br />
<br />
<img alt="Blend3.gif" border="0" height="376" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6618/Images/Blend3.gif" width="624" /><br />
<br />
As marked in screenshot.<br />
<br />
<b>Project Types</b><br />
<br />
In the above screenshot, look at the red rectangle. There are two project type options available; Silverlight and WPF. Here are some major differences between them.<br />
<br />
Silverlight and WPF (Windows Presentation Foundation) are two different products from Microsoft, but they have lots of overlap. WPF is a Microsoft technology meant for developing enhanced graphics applications for desktop platform. In addition, WPF applications can be hosted on web browsers which offer rich graphics features for web applications, but it is limited to Operating Systems. Web Browser Applications (WBA), developed on WPF technology uses XAML (read as Zameel) to host user interface for browser applications. XAML stands for eXtended Application Markup Language which is a new declarative programming model from Microsoft. XAML files are hosted as discrete files in the Web server, but are downloaded to the browsers and converted to user interface by the .NET runtime in the client browsers. WPF runs on .NET runtime and developers can take advantage of the rich .NET Framework and WPF libraries to build really cool windows applications. WPF supports 3-D graphics, complex animations, hardware acceleration etc.</span> <br />
<a name='more'></a><br />
<ul><li><span style="font-family: Verdana;">Silverlight is simply a subset of WPF.</span> </li>
<li><span style="font-family: Verdana;">Silverlight is meant to be used online, while WPF is for local use.</span> </li>
<li><span style="font-family: Verdana;">You can use Silverlight applications regardless of the operating system you use, while WPF applications are restricted to later versions of the Windows operating system.</span> </li>
<li><span style="font-family: Verdana;">Silverlight lacks access to local resources, while WPF can utilize local resources.</span> </li>
<li><span style="font-family: Verdana;">Silverlight only has perspective 3D support, while WPF is capable of full 3D images.</span></li>
</ul><br />
<span style="font-family: Verdana;">Now come back to our topic, after selecting Silverlight from "Project Types", you will see five project categories. <br />
<br />
<b>Silverlight Application + Website</b><br />
<br />
A project with an associated website for creating rich cross-platform, web-based applications. <br />
<br />
<b>Silverlight Application</b><br />
<br />
A project for creating rich cross-platform, web-based applications but without an associated website.<br />
<br />
<b>Silverlight Databound Application</b><br />
A project that uses data and command bindings to support loose coupling between View and ViewModel.<br />
<br />
<b>Silverlight Control Library</b><br />
<br />
A project for creating custom controls that can be reused across other Silverlight applications. <br />
<br />
<b>Silverlight SketchFlow Application</b><br />
<br />
A project for prototyping rich cross-platform, web-based applications.<br />
<br />
Finally, use the first one that is "Silverlight Application + Website" and select Name, Location, Language and Version whatever you wish. Using here the default. Ok...look at the screen when we click ok button. <br />
<br />
<img alt="Blend4.gif" border="0" height="446" src="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6618/Images/Blend4.gif" width="624" /></span><br />
<br />
<span style="font-family: Verdana;">READ MORE>></span><br />
<span style="font-family: Verdana; font-size: x-small;"><a href="http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6618/"><span style="font-size: small;">http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/6618</span>/</a></span></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-39919614891219550532011-04-06T22:16:00.000-07:002011-04-06T22:16:56.342-07:00Creating nice tab feature in Silverlight<div dir="ltr" style="text-align: left;" trbidi="on"><div style="text-align: justify;"><span style="font-family: Verdana;">This article uses cool animation in silverlight to create a tab bar like look. Create two custom button controls in the sample for the two tabs you see in the picture above.</span><span style="font-family: Verdana;"><b></b></span> </div><a name='more'></a><div style="text-align: justify;"><br />
</div><div style="text-align: justify;"><span style="font-family: Verdana;"><b>Creating a custom button</b><br />
For creating a custom button, you just have to place a button control into the work area. Right click the button control and select "Edit Control Parts (Template)" and then select "Create Empty". This will create an empty button control to work with.<br />
<br />
Now you can use any of the other controls like rectangle, ellipse, textblock to create you custom button control.<br />
<br />
Here in my sample, place one rectangle and textblock to create custom button. In sample, you can see two button control for the two tabs.<br />
<br />
<img align="baseline" alt="" border="0" hspace="0" src="http://www.c-sharpcorner.com/UploadFile/prvn_131971/CreatingtabfeatureSilverlight11252008062329AM/Images/buttonimage.gif" /><br />
<br />
Code for the two button's are:<br />
<br />
<span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Button</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="72"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Width</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="184"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Canvas.Left</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="72"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Canvas.Top</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="80"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Content</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Button"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Template</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="{</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StaticResource</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ButtonControlTemplate2</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">}"/><br />
<br />
<</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Button</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="32"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Width</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="175"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Canvas.Left</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="8"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Canvas.Top</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="12"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Content</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Button"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Template</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="{</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">StaticResource</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ButtonControlTemplate3</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">}"/></span></div><div class="MsoNormal" style="text-align: left;"><span style="font-family: Verdana; font-size: 10pt; line-height: 115%;">Code for control template<span style="color: #a31515;"> "</span><span style="color: red;">ButtonControlTemplate2" </span>is as follows:</span></div><div class="MsoNormal" style="text-align: left;"><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ControlTemplate</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Key</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="ButtonControlTemplate2"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> TargetType</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Button"></span></div><div class="MsoNormal" style="text-align: left;"><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="32"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateManager.VisualStateGroups</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateGroup</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="FocusStates"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Unfocused"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Focused"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateGroup</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateGroup</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="CommonStates"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateGroup.Transitions</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualTransition</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:02"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> To</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="MouseOver"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualTransition</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:02"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> From</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="MouseOver"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> To</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Normal"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateGroup.Transitions</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="MouseOver"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Storyboard</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="10"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame.KeySpline</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">KeySpline</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ControlPoint1</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0,0"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ControlPoint2</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="1,1"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame.KeySpline</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="91.481"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame.KeySpline</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">KeySpline</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ControlPoint1</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0,0"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ControlPoint2</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0.740000009536743,0.014"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame.KeySpline</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.Opacity)"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="1"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame.KeySpline</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">KeySpline</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ControlPoint1</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0,0"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> ControlPoint2</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0.26800000667572,1"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame.KeySpline</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ObjectAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.Visibility)"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> RepeatBehavior</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Forever"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame.Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Visibility</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Visible</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Visibility</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame.Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ObjectAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="88.009"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SplineDoubleKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="1.962"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DoubleAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ObjectAnimationUsingKeyFrames</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> BeginTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Duration</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00.0010000"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetName</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="textBlock"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Storyboard.TargetProperty</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="(UIElement.Visibility)"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> KeyTime</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="00:00:00"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame.Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Visibility</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Visible</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Visibility</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame.Value</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">DiscreteObjectKeyFrame</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ObjectAnimationUsingKeyFrames</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Storyboard</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Pressed"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Disabled"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualState</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Normal"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateGroup</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">vsm</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">VisualStateManager.VisualStateGroups</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">>|</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Rectangle</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> HorizontalAlignment</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Stretch"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Margin</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0,0,0,0"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> VerticalAlignment</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Top"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="32"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Fill</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="#FFEE916F"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Rectangle</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="16"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> HorizontalAlignment</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Stretch"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Margin</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="1,0,0.0209999997168779,-0.526000022888184"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> VerticalAlignment</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Bottom"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="rectangle"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> RenderTransformOrigin</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="0.5,0.5"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Opacity</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="1"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> d</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">IsHidden</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="False"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Visibility</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Visible"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Fill</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="#FFEE916F"></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Rectangle.RenderTransform</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TransformGroup</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ScaleTransform</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">SkewTransform</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">RotateTransform</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Angle</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="-0.338"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TranslateTransform</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TransformGroup</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Rectangle.RenderTransform</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Rectangle</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Height</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="136"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Margin</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="8,0,-152,-152"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> VerticalAlignment</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Bottom"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Indians in Malaysia will appeal for PM Badawai's intervention over the ban on yoga. They said that yoga was an ancient Indian art form and that no religious connotations should be attached to it."</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> TextWrapping</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Wrap"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> FontSize</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="14"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> FontWeight</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Normal"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Visibility</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Collapsed"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> x</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">:</span><span style="color: red; font-family: Verdana; font-size: 10pt;">Name</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="textBlock"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="color: blue; font-family: Verdana; font-size: 10pt;"><</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">TextBlock</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Margin</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="21,4,24,7"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> Text</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Breaking News"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> TextWrapping</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Wrap"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> FontSize</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="16"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> FontWeight</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Bold"</span><span style="color: red; font-family: Verdana; font-size: 10pt;"> FontFamily</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">="Verdana"/></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> <br />
</span><span style="color: blue; font-family: Verdana; font-size: 10pt;"></</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">Grid</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">><br />
</</span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;">ControlTemplate</span><span style="color: blue; font-family: Verdana; font-size: 10pt;">></span><span style="color: #a31515; font-family: Verdana; font-size: 10pt;"> </span><span style="font-family: Verdana; font-size: x-small;"><br />
<span style="font-size: small;">The control template "ButtonControlTemplate3" is similar to the above code with slight changes in position. <br />
In the above control template,applied some animation to postion the content for the tab. For the tab content,used one rectangle and a textblock inside the rectangle.</span></span></div><div class="MsoNormal" style="text-align: left;"><span style="font-family: Verdana; font-size: x-small;"><span style="font-size: small;"><br />
</span></span><div class="MsoNormal"><span style="font-family: Verdana;">READ MORE>></span></div><div class="MsoNormal"><span style="font-family: Verdana;"><a href="http://www.c-sharpcorner.com/UploadFile/prvn_131971/CreatingtabfeatureSilverlight11252008062329AM/CreatingtabfeatureSilverlight.aspx">http://www.c-sharpcorner.com/UploadFile/prvn_131971/CreatingtabfeatureSilverlight11252008062329AM/CreatingtabfeatureSilverlight.aspx</a></span></div></div></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0tag:blogger.com,1999:blog-1783751456272579759.post-17844835493401930262011-04-05T22:17:00.000-07:002011-04-05T22:17:06.635-07:00SelectedValue and SelectedValuePath in Silverlight 4<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Verdana;">In this article we will see about SelectedValue and SelectedValuePath while Binding. This feature is added in Silverlight 4.</span><br />
<br />
<a name='more'></a><br />
<b>SelectedValue and SelectedValuePath</b><br />
<br />
These properties enable a ComboBox to behave as a look up table, that means a value can be displayed in ComboBox but when selected another property would be selected.<br />
<br />
Let's do a sample where we can see it.<br />
<br />
Let's have a ComboBox to display the data and a TextBlock which will display another property of the bound data of ComboBox.<br />
<br />
Let's have sample data which can be bound to ComboBox.<br />
<br />
<img alt="image1.gif" border="0" height="92" src="http://www.c-sharpcorner.com/UploadFile/dpatra/1092/Images/image1.gif" width="308" /><br />
<br />
The above class represents a sample Employee Entity structure.<br />
<br />
<img alt="image2.gif" border="0" height="332" src="http://www.c-sharpcorner.com/UploadFile/dpatra/1092/Images/image2.gif" width="558" /><br />
<br />
Now in xaml we need to do proper binding as follows:<br />
<br />
<img alt="image3.gif" border="0" height="230" src="http://www.c-sharpcorner.com/UploadFile/dpatra/1092/Images/image3.gif" width="615" /><br />
<br />
As you see in above xaml display, we have set the SelectedValuePath which is different from the displaying Path. In our case SelectedValuePath is "EmailID" and for display it is "EmployeeName".<br />
<br />
In the TextBlock, the Text property is bound to the SelectedValue of the Element ComboBox.<br />
READ MORE >> <a href="http://www.c-sharpcorner.com/UploadFile/dpatra/1092/">http://www.c-sharpcorner.com/UploadFile/dpatra/1092/</a></div>Dotnethttp://www.blogger.com/profile/18284658622300215283noreply@blogger.com0