<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1858172642880296245</id><updated>2023-09-15T20:31:51.005+05:30</updated><category term="WPF"/><category term="Asp.Net Examples"/><category term="Asp.Net"/><category term="C#"/><category term="OopsConcepts"/><category term=".Net"/><category term="C#.Net"/><category term="Data Binding in WPF"/><category term="StateManageMent Techniques in Asp.net"/><category term="clinet-side statemanagement"/><category term="Ado.Net"/><category term="Error Solving"/><category term="Asp.Net Validation Controls"/><category term="Windows Forms"/><category term="Connection String"/><category term="Three Tier Architecture"/><category term="Visual Studio Errors"/><category term="Access Specifiers"/><category term="Ajax"/><category term="App.Config"/><category term="Asp.Net Ajax"/><category term="Asp.Net Server Controls"/><category term="BloggerTips"/><category term="QueryString in Asp.Net"/><category term="Setting file"/><category term="XAML"/><category term=".Net Interview Questions"/><category term="Animation Examples"/><category term="Asp.Net Ajax Examples"/><category term="Attribute Syntx"/><category term="Binding Modes"/><category term="Control rendering."/><category term="Cookies."/><category term="Dialog Controls"/><category term="DoubleAnimation"/><category term="Drawings"/><category term="GroupBox"/><category term="Markup Extensions"/><category term="Multilingual Website"/><category term="Object Hierarchy"/><category term="Property Element Syntax"/><category term="RequiredFieldValidator in asp.net"/><category term="RichTextBox"/><category term="Shapes"/><category term="Sql Server"/><category term="Static Resource example"/><category term="Tags"/><category term="UpdateSourceTrigger"/><category term="VB.Net"/><category term="ViewState"/><category term="WPF Controls"/><category term="Web Translation"/><category term="XAML file Compilation"/><category term="code behind"/><category term="configuration Files"/><category term="html"/><title type='text'>Sekhar Babu</title><subtitle type='html'>AspDotNet Sekhar offer tutorials on WPF Tutorials, C# Tutorials and Examples, Asp.Net Tutorials and Examples ,Oops Tutorials, Seo Tips, Blogger Tips etc.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default?start-index=26&amp;max-results=25'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>59</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4598581747027612111</id><published>2017-11-12T01:03:00.000+05:30</published><updated>2017-11-12T01:10:09.235+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Error Solving"/><category scheme="http://www.blogger.com/atom/ns#" term="Sql Server"/><title type='text'>Sql Server - Fix Error - Can not use the backup file because it was originally formatted with 512 and is now on a device with sector size 4096 </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Recently i encountered Sql Server Error when i try to take backup of database from SSMS (Sql Server Management Studio) i.e&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;System.Data.SqlClient.SqlError : can not use the backup file &quot;path&quot; because it was originally formatted with sector size 512 and is now on a device with sector size 4096&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://1.bp.blogspot.com/-zS-rNa3DMk8/WgdOYYOr_uI/AAAAAAAAByE/LmJ-KPNfq6sd-awuVCcJ2nmz5NC2dMV_wCLcBGAs/s1600/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;359&quot; src=&quot;https://1.bp.blogspot.com/-zS-rNa3DMk8/WgdOYYOr_uI/AAAAAAAAByE/LmJ-KPNfq6sd-awuVCcJ2nmz5NC2dMV_wCLcBGAs/s640/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Problem is , backup file which was created with different sector size , so it is not possible now to use it. So &lt;b&gt;solution is remove that backup file&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://4.bp.blogspot.com/-RNT2yy4B3Mc/WgdPQlP454I/AAAAAAAAByM/5iwHdJ4UJcAugSWAI20n217e0dc4gnUbwCLcBGAs/s1600/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096-remove-error.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;359&quot; src=&quot;https://4.bp.blogspot.com/-RNT2yy4B3Mc/WgdPQlP454I/AAAAAAAAByM/5iwHdJ4UJcAugSWAI20n217e0dc4gnUbwCLcBGAs/s640/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096-remove-error.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now add the new file for taking backup and ok&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://3.bp.blogspot.com/-npvT1Q9rygY/WgdQBYBj_XI/AAAAAAAAByU/wTZtZtzlN180_Ec92qVXU-6YmSpr8YYcQCLcBGAs/s1600/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096-remove-error-success.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;359&quot; src=&quot;https://3.bp.blogspot.com/-npvT1Q9rygY/WgdQBYBj_XI/AAAAAAAAByU/wTZtZtzlN180_Ec92qVXU-6YmSpr8YYcQCLcBGAs/s640/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096-remove-error-success.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
That&#39;s it simple. Just remove the old backup file with different sector size.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4598581747027612111/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/11/sql-server-fix-error-can-not-use-backup-file-because-it-was-originally-formatted-with-512-and-is-now-on-a-device-with-sector-size-4096-solve.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4598581747027612111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4598581747027612111'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/11/sql-server-fix-error-can-not-use-backup-file-because-it-was-originally-formatted-with-512-and-is-now-on-a-device-with-sector-size-4096-solve.html' title='Sql Server - Fix Error - Can not use the backup file because it was originally formatted with 512 and is now on a device with sector size 4096 '/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-zS-rNa3DMk8/WgdOYYOr_uI/AAAAAAAAByE/LmJ-KPNfq6sd-awuVCcJ2nmz5NC2dMV_wCLcBGAs/s72-c/Sql-Server-Fix-because-it-was-originally-formatted-with-sector-size-512-and-is-now-on-a-device-with-sector-size-4096.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-263175750086998437</id><published>2017-10-27T05:37:00.000+05:30</published><updated>2017-10-27T05:37:30.475+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Error Solving"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio Errors"/><title type='text'>[Solved] C# - OriginalValues cannot be used for entities in the Added state Visual Studio Error</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Hi, recently i encountered runtime error when i try to insert values using Entity Framework&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&quot;OriginalValues cannot be used for entities in the Added state&quot;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;This could &lt;/b&gt;arise because &lt;b&gt;missing column or inserting null value or column width exceeding&lt;/b&gt; in insert statement.&lt;br /&gt;
&lt;br /&gt;
You can find the error message in Exception object&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
$exception.EntityValidationErrors[n].ValidationErrors[n].ErrorMessage&lt;br /&gt;
$exception.EntityValidationErrors[n].ValidationErrors[n].PropertyName&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://2.bp.blogspot.com/-zettU5LChps/WfJ3PwSZ_CI/AAAAAAAABxo/J34IsMe4kKMxD4cS065repaFS89UOcMrQCLcBGAs/s1600/originalvalues-cannot-be-used-for-entities-in-the-added-state-c%2523-visual-studio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; src=&quot;https://2.bp.blogspot.com/-zettU5LChps/WfJ3PwSZ_CI/AAAAAAAABxo/J34IsMe4kKMxD4cS065repaFS89UOcMrQCLcBGAs/s1600/originalvalues-cannot-be-used-for-entities-in-the-added-state-c%2523-visual-studio.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Based on your Error Message you can take corrective action to rectify this.&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/263175750086998437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/10/Csharp-originalvalues-cannot-be-used-for-entities-in-the-added-state.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/263175750086998437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/263175750086998437'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/10/Csharp-originalvalues-cannot-be-used-for-entities-in-the-added-state.html' title='[Solved] C# - OriginalValues cannot be used for entities in the Added state Visual Studio Error'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-zettU5LChps/WfJ3PwSZ_CI/AAAAAAAABxo/J34IsMe4kKMxD4cS065repaFS89UOcMrQCLcBGAs/s72-c/originalvalues-cannot-be-used-for-entities-in-the-added-state-c%2523-visual-studio.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-2710737947006879001</id><published>2017-09-29T08:56:00.000+05:30</published><updated>2017-10-27T05:38:10.477+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Error Solving"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio Errors"/><title type='text'>[SOLVED] access denied  can not execute the program  csc.exe  after publishing .net application web deploy mvc  app</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Hi, Recently i encountered this error after publishing an application to winhost server.&lt;br /&gt;
&lt;br /&gt;
Error stacktrace is&lt;br /&gt;
&lt;pre style=&quot;background-color: #ffffcc; font-family: Consolas, &amp;quot;Lucida Console&amp;quot;, monospace; font-size: 11pt; line-height: 14pt; padding: 0.5em;&quot;&gt;[Win32Exception (0x80004005): Access is denied]

[ExternalException (0x80004005): Cannot execute a program. The command being &lt;/pre&gt;
&lt;pre style=&quot;background-color: #ffffcc; font-family: Consolas, &amp;quot;Lucida Console&amp;quot;, monospace; font-size: 11pt; line-height: 14pt; padding: 0.5em;&quot;&gt;executed was &quot;E:\web\nrgwareh\bin\roslyn\csc.exe&quot;&lt;/pre&gt;
&lt;br /&gt;
It is an mvc application using visual studio 2017 , targeted framework is 4.6.2.&lt;br /&gt;
&lt;br /&gt;
I just published using webdeploy method. it is successfully deployed but when i try to run i encountered this one like&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://4.bp.blogspot.com/-v4eKUAUrkrE/Wc25b0-Qm3I/AAAAAAAABw4/VaKpZPt2liMHfx8DT66BXblHNpKQgs_-gCLcBGAs/s1600/access%2Bis%2Bdenied%2Bcan%2Bnot%2Bexecute%2Ba%2Bprogram%2Bthe%2Bcomman%2Bbeing%2Bexecuted%2Bcsc.exe%2Broslyn%2B%2B.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;356&quot; src=&quot;https://4.bp.blogspot.com/-v4eKUAUrkrE/Wc25b0-Qm3I/AAAAAAAABw4/VaKpZPt2liMHfx8DT66BXblHNpKQgs_-gCLcBGAs/s640/access%2Bis%2Bdenied%2Bcan%2Bnot%2Bexecute%2Ba%2Bprogram%2Bthe%2Bcomman%2Bbeing%2Bexecuted%2Bcsc.exe%2Broslyn%2B%2B.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
when i run locally its working fine. But here problem is winhost doesn&#39;t allow csc.exe to run which is roslyn compilation.&lt;br /&gt;
&lt;br /&gt;
When we create a web application either webforms or mvc using .net framework 4.5 &amp;gt; then project is pre installed with roslyn csc.exe compilation. although it was successfully published to hosting environment, but some servers doesn&#39;t allow to run that roslyn compiler.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution 1:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Here solution is just compile and deploy project without any roslyn or any csc.exe files.&lt;br /&gt;
&lt;br /&gt;
just go to Nuget manager, find&amp;nbsp; the package &lt;b&gt;Microsoft.CodeDom.Provider.DotnetCompilerPlatform , uninstall it.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://4.bp.blogspot.com/-MfRAaSX2FiY/Wc28Nyc5TrI/AAAAAAAABxE/UCI8TSgX_VI3A2VW0y-j3nllyJ9311MkgCLcBGAs/s1600/un%2Binstall%2Bcodedom%2Broslyn%2Bcsc.exe%2B.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;358&quot; src=&quot;https://4.bp.blogspot.com/-MfRAaSX2FiY/Wc28Nyc5TrI/AAAAAAAABxE/UCI8TSgX_VI3A2VW0y-j3nllyJ9311MkgCLcBGAs/s640/un%2Binstall%2Bcodedom%2Broslyn%2Bcsc.exe%2B.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Now rebuild and re publish, then this problem gone away.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution 2:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;In some hosting environments we have option to allow or run csc.exe files, just change that setting or allow read/write to exe files, it get&#39;s fixed.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Hope it can be useful to some folks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
</content><link rel="related" href="http://www.aspdotnet-sekhar.com/2017/09/solved-access-denied-can-not-execute-comman-being-executed-was-csc-exe-publishing-web-app-net-mvc.html" title="[SOLVED] access denied  can not execute the program  csc.exe  after publishing .net application web deploy mvc  app"/><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/2710737947006879001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/09/solved-access-denied-can-not-execute-comman-being-executed-was-csc-exe-publishing-web-app-net-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2710737947006879001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2710737947006879001'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/09/solved-access-denied-can-not-execute-comman-being-executed-was-csc-exe-publishing-web-app-net-mvc.html' title='[SOLVED] access denied  can not execute the program  csc.exe  after publishing .net application web deploy mvc  app'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://4.bp.blogspot.com/-v4eKUAUrkrE/Wc25b0-Qm3I/AAAAAAAABw4/VaKpZPt2liMHfx8DT66BXblHNpKQgs_-gCLcBGAs/s72-c/access%2Bis%2Bdenied%2Bcan%2Bnot%2Bexecute%2Ba%2Bprogram%2Bthe%2Bcomman%2Bbeing%2Bexecuted%2Bcsc.exe%2Broslyn%2B%2B.png" height="72" width="72"/><thr:total>0</thr:total><georss:featurename>India,us,china,russia,uk</georss:featurename><georss:point>20.593684 78.962880000000041</georss:point><georss:box>-8.6044825 37.654286000000042 49.791850499999995 120.27147400000004</georss:box></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4342898438940287087</id><published>2017-09-05T12:33:00.002+05:30</published><updated>2017-10-27T05:38:38.670+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Error Solving"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio Errors"/><title type='text'>[Solved] Extender Provider failed to return an Extender for this project - Visual Studio Community 2015</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
Hi.., Recently i encountered visual studio designer exception when i try to open EDM file in visual studio &quot;&amp;nbsp;Extender Provider failed to return an Extender for this project &quot; like this below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://3.bp.blogspot.com/-wefJRYtyQ5M/Wa5Ly9q0WEI/AAAAAAAABwc/HpySETT7-80KxmIv39ZF8kLmYSQjJ-dIQCLcBGAs/s1600/The%2BExtender%2BProvider%2Bfailed%2Bto%2Breturn%2Ban%2BExtender%2Bfor%2Bthis%2Bobject%2Bc%2523-%2Bvisual%2Bstudio.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;473&quot; data-original-width=&quot;1018&quot; height=&quot;296&quot; src=&quot;https://3.bp.blogspot.com/-wefJRYtyQ5M/Wa5Ly9q0WEI/AAAAAAAABwc/HpySETT7-80KxmIv39ZF8kLmYSQjJ-dIQCLcBGAs/s640/The%2BExtender%2BProvider%2Bfailed%2Bto%2Breturn%2Ban%2BExtender%2Bfor%2Bthis%2Bobject%2Bc%2523-%2Bvisual%2Bstudio.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Problem is i have been running the application 5 hours plus time, without stopping in local.&lt;br /&gt;
&lt;br /&gt;
Then when i try to view edmx file, encounter this exception.&lt;br /&gt;
&lt;br /&gt;
To stop this exception just reload the project so that all objects gets created again and available to view.&lt;br /&gt;
&lt;br /&gt;
When an application is running idle for hours, it is better to reload that project.&lt;br /&gt;
&lt;br /&gt;
You don&#39;t have to delete obj and bin folders. But for different situations it may work. Possibly when this exception encountered while in working in designer mode by simply reloading project, you can remove that exception.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4342898438940287087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/09/solved-extender-provider-failed-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4342898438940287087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4342898438940287087'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/09/solved-extender-provider-failed-to.html' title='[Solved] Extender Provider failed to return an Extender for this project - Visual Studio Community 2015'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://3.bp.blogspot.com/-wefJRYtyQ5M/Wa5Ly9q0WEI/AAAAAAAABwc/HpySETT7-80KxmIv39ZF8kLmYSQjJ-dIQCLcBGAs/s72-c/The%2BExtender%2BProvider%2Bfailed%2Bto%2Breturn%2Ban%2BExtender%2Bfor%2Bthis%2Bobject%2Bc%2523-%2Bvisual%2Bstudio.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-1760410024290514385</id><published>2017-02-18T11:46:00.000+05:30</published><updated>2017-02-18T11:46:01.557+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Error Solving"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Forms"/><title type='text'>[Solved] :  failed to create component &#39;Report Viewer&#39; System.runtime.interopservices.COMException(0x8004D745)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Hi there. Recently i encountered this error when i migrated visual studio 2008 windows application to vs 2012 . Here i am dragging &amp;nbsp;report viewer to control on windows form, then i encountered a long list of error message&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://4.bp.blogspot.com/-h0oPnC05KA0/WKfkguVOfPI/AAAAAAAABts/rUw06NSCZbA8lC-KvpxrL10FbNpc-xTlQCLcB/s1600/failed%2Bto%2Bcreate%2Bcomponent%2BReportViewer%2B%2BSystem.Runtime.interopservices.ComException%2Ba%2Breference%2Bto%2Bcomponent%2Balready%2Bexist%2Bin%2Bthe%2Bproject%2B%2B.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://4.bp.blogspot.com/-h0oPnC05KA0/WKfkguVOfPI/AAAAAAAABts/rUw06NSCZbA8lC-KvpxrL10FbNpc-xTlQCLcB/s1600/failed%2Bto%2Bcreate%2Bcomponent%2BReportViewer%2B%2BSystem.Runtime.interopservices.ComException%2Ba%2Breference%2Bto%2Bcomponent%2Balready%2Bexist%2Bin%2Bthe%2Bproject%2B%2B.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Problem is project reference is enabled for version 10.0.0 for report viewer but toolbox is adding 11.0.0.0 version.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Solution: just add the System.ReportViewer.Winforms 11.0.0.0 version remove 10.0.0.0 version.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
You will get these kind of designer errors when you migrate to higher version. Just check the references added to project properly.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Hope it helps you.&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/1760410024290514385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/02/solved-failed-to-create-component-reportviewer-a-reference-to-component-already-exist-in-the-project.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1760410024290514385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1760410024290514385'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2017/02/solved-failed-to-create-component-reportviewer-a-reference-to-component-already-exist-in-the-project.html' title='[Solved] :  failed to create component &#39;Report Viewer&#39; System.runtime.interopservices.COMException(0x8004D745)'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://4.bp.blogspot.com/-h0oPnC05KA0/WKfkguVOfPI/AAAAAAAABts/rUw06NSCZbA8lC-KvpxrL10FbNpc-xTlQCLcB/s72-c/failed%2Bto%2Bcreate%2Bcomponent%2BReportViewer%2B%2BSystem.Runtime.interopservices.ComException%2Ba%2Breference%2Bto%2Bcomponent%2Balready%2Bexist%2Bin%2Bthe%2Bproject%2B%2B.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-1719604768748381333</id><published>2013-08-21T15:15:00.000+05:30</published><updated>2015-01-17T00:58:55.189+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Binding in WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Data Binding with WPF : Binding to XML</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article i will explain &lt;b&gt;How to bind XML Data to Application UI in WPF. What are the different ways to specify the XML Data to Applicaiton, How to bind the xml elements to UI in wpf etc.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://app.box.com/s/eitbmzv9t17o4r0hy6g1&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download SourceCode&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=1pVQ-VTcM18&quot; target=&quot;_blank&quot;&gt;Video Explaining How to bind Xml Data to ListBox in WPF&lt;/a&gt;&amp;nbsp; &lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; In wpf for accessing xml data in your application you can use &lt;b&gt;XmlDataProvider&lt;/b&gt; Class. This class provides declarative access to xml data for binding.&lt;b&gt; XmlDataProvider&lt;/b&gt; Class provides three ways to access XML Data.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;You can&lt;b&gt; embed inline XML Data&lt;/b&gt; within the &lt;x:xdata&gt; tag inside &lt;b&gt;XmlDataProvider&lt;/b&gt; Class.&lt;/x:xdata&gt;&lt;/li&gt;
&lt;li&gt;You can use&lt;b&gt; Source&lt;/b&gt; to specify the Uri of the XML file.&lt;/li&gt;
&lt;li&gt;You can use&lt;b&gt; Document&lt;/b&gt; property to specify the &lt;b&gt;XmlDocument&lt;/b&gt; as binding source.&lt;/li&gt;
&lt;/ol&gt;
One Important property of &lt;b&gt;XmlDataProvider&lt;/b&gt; Class is &lt;b&gt;XPath&lt;/b&gt; which &lt;b&gt;defines the level binding source in XML file.&lt;/b&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Embedding Inline XML Data:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/div&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;window x:Class=&quot;DataBindings.XMLData&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        Title=&quot;XMLData&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;
    &lt;Window.Resources&gt;
        &lt;xmldataprovider x:Key=&quot;AuthorNames&quot; XPath=&quot;Authors&quot;&gt;
            &lt;x:XData&gt;
                &lt;authors xmlns=&quot;&quot;&gt;
                    &lt;author name=&quot;Sekhar Babu&quot; age=&quot;23&quot;/&gt;
                    &lt;author name=&quot;Mani Sharma&quot; age=&quot;45&quot;/&gt;
                    &lt;author name=&quot;Hanselman&quot; age=&quot;45&quot;/&gt;
                    &lt;author name=&quot;Scott&quot; age=&quot;50&quot;/&gt;
                    &lt;author name=&quot;Kunal&quot; age=&quot;34&quot;/&gt;
                &lt;/Authors&gt;

            &lt;/x:XData&gt;
        &lt;/XmlDataProvider&gt;

    &lt;/Window.Resources&gt;
    &lt;grid&gt;
     
        &lt;listbox  x:Name=&quot;ListAuthors&quot; Grid.Row=&quot;1&quot;  ItemsSource=&quot;{Binding Source={StaticResource AuthorNames}, XPath=*}&quot;  &gt;
            &lt;ListBox.ItemTemplate&gt;
                &lt;datatemplate&gt;
                   
                        &lt;grid&gt;
                            &lt;Grid.ColumnDefinitions&gt;
                                &lt;columndefinition Width=&quot;100&quot;/&gt;
                                &lt;ColumnDefinition/&gt;
                            &lt;/Grid.ColumnDefinitions&gt;
                        &lt;textblock Grid.Column=&quot;0&quot; Foreground=&quot;Red&quot;  Text=&quot;{Binding XPath=@name}&quot;/&gt;
                        &lt;textblock Foreground=&quot;Blue&quot; Text=&quot;{Binding XPath=@age}&quot; Grid.Column=&quot;1&quot;/&gt;
                      
                        &lt;/Grid&gt;
                   
                &lt;/DataTemplate&gt;
            &lt;/ListBox.ItemTemplate&gt;
        &lt;/ListBox&gt;
        
    &lt;/Grid&gt;
&lt;/Window&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If you see the XAML code XML Data is embed with in &lt;x:xdata&gt; tag. This XML file has root element as Authors and child element Author with two attributes name and age.&lt;/x:xdata&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So for accessing these XML element in ListBox, i specified the itemsource to AuthorNames, XPath=* means it will returns all the data in XML. We can use XPath to query against the XML data&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
XPath=*[@age&amp;gt;25] will returns the Authors whose age is greater than 25. In this way query against Data.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Accessing XML Data By Setting Source:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I Have an XML File as Follows:&lt;/h4&gt;
&lt;textarea class=&quot;xml&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;

&lt;stock xmlns=&quot;&quot;&gt;
  &lt;mobiles&gt;
    &lt;mobile Brand=&quot;Nokia&quot;&gt;
      &lt;model&gt;N947&lt;/Model&gt;
      &lt;stock&gt;10&lt;/Stock&gt;
      &lt;price&gt;7500&lt;/Price&gt;
    &lt;/Mobile&gt;
    &lt;mobile Brand=&quot;Nokia&quot;&gt;
      &lt;model&gt;N347&lt;/Model&gt;
      &lt;stock&gt;150&lt;/Stock&gt;
      &lt;price&gt;9000&lt;/Price&gt;

    &lt;/Mobile&gt;
    &lt;mobile Brand=&quot;Nokia&quot;&gt;
      &lt;model&gt;N147&lt;/Model&gt;
      &lt;stock&gt;10&lt;/Stock&gt;
      &lt;price&gt;13000&lt;/Price&gt;

    &lt;/Mobile&gt;
    &lt;mobile Brand=&quot;Samsung&quot;&gt;
      &lt;model&gt;N197&lt;/Model&gt;
      &lt;stock&gt;100&lt;/Stock&gt;
      &lt;price&gt;31000&lt;/Price&gt;

    &lt;/Mobile&gt;
    &lt;mobile Brand=&quot;Samsung&quot;&gt;
      &lt;model&gt;N127&lt;/Model&gt;
      &lt;stock&gt;100&lt;/Stock&gt;
      &lt;price&gt;31000&lt;/Price&gt;

    &lt;/Mobile&gt;
    &lt;mobile Brand=&quot;Samsung&quot;&gt;
      &lt;model&gt;N1937&lt;/Model&gt;
      &lt;stock&gt;100&lt;/Stock&gt;
      &lt;price&gt;31000&lt;/Price&gt;

    &lt;/Mobile&gt;
    &lt;mobile Brand=&quot;Samsung&quot;&gt;
      &lt;model&gt;N1957&lt;/Model&gt;
      &lt;stock&gt;100&lt;/Stock&gt;
      &lt;price&gt;31000&lt;/Price&gt;

    &lt;/Mobile&gt;
  &lt;/Mobiles&gt;
  &lt;cds&gt;
    &lt;cd Brand=&quot;Panasonic&quot;&gt;
      &lt;model&gt;121&lt;/Model&gt;
      &lt;stock&gt;300&lt;/Stock&gt;
      &lt;price&gt;20&lt;/Price&gt;
    &lt;/CD&gt;
    &lt;cd Brand=&quot;Panasonic&quot;&gt;
      &lt;model&gt;121&lt;/Model&gt;
      &lt;stock&gt;300&lt;/Stock&gt;
      &lt;price&gt;20&lt;/Price&gt;
    &lt;/CD&gt;
    &lt;cd Brand=&quot;Zoom&quot;&gt;
      &lt;model&gt;111&lt;/Model&gt;
      &lt;stock&gt;300&lt;/Stock&gt;
      &lt;price&gt;20&lt;/Price&gt;
    &lt;/CD&gt;
    &lt;cd Brand=&quot;Zoom&quot;&gt;
      &lt;model&gt;101&lt;/Model&gt;
      &lt;stock&gt;300&lt;/Stock&gt;
      &lt;price&gt;20&lt;/Price&gt;
    &lt;/CD&gt;    
  &lt;/CDs&gt;
&lt;/Stock&gt;
&lt;/textarea&gt; 
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
I am displaying these data in UI as follows&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-IXy4zLUPK0Y/UgyTmeFEjhI/AAAAAAAAA3Y/tMYukNTylTk/s1600/XML+Data+Accessing.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Accessing XML Data Using XmlDataProvider&quot; border=&quot;0&quot; height=&quot;496&quot; src=&quot;http://2.bp.blogspot.com/-IXy4zLUPK0Y/UgyTmeFEjhI/AAAAAAAAA3Y/tMYukNTylTk/s640/XML+Data+Accessing.png&quot; title=&quot;Binding XML Data to WPF UI&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Here is the XAML Code:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;window x:Class=&quot;XMLData.Window1&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;453&quot;&gt;
    
    &lt;Window.Resources&gt;
        &lt;xmldataprovider x:Key=&quot;Data&quot; Source=&quot;/XMLFile1.xml&quot; /&gt;
    &lt;/Window.Resources&gt;
    
    &lt;grid&gt;
        &lt;combobox Height=&quot;23&quot; ItemsSource=&quot;{Binding Source={StaticResource Data}, XPath=/Stock/* }&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;18,14,0,0&quot; x:Name=&quot;comboBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; &gt;
            &lt;ComboBox.ItemTemplate&gt;
                &lt;datatemplate&gt;
                    &lt;textblock Text=&quot;{Binding Name}&quot;/&gt;                   
                &lt;/DataTemplate&gt;
            &lt;/ComboBox.ItemTemplate&gt;
        &lt;/ComboBox&gt;
        &lt;stackpanel Orientation=&quot;Horizontal&quot; DataContext=&quot;{Binding ElementName=comboBox1,Path=SelectedItem}&quot;&gt;
            &lt;listbox Height=&quot;100&quot; ItemsSource=&quot;{Binding Path=ChildNodes}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;16,53,0,0&quot; Name=&quot;listBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot;&gt;
                &lt;ListBox.ItemTemplate&gt;
                    &lt;datatemplate&gt;
                        &lt;textblock Text=&quot;{Binding XPath=Model}&quot; /&gt;
                    &lt;/DataTemplate&gt;
                &lt;/ListBox.ItemTemplate&gt;
            &lt;/ListBox&gt;
            &lt;stackpanel Margin=&quot;16,0,0,0&quot; DataContext=&quot;{Binding ElementName=listBox1, Path=SelectedItem}&quot; Width=&quot;191&quot; Height=&quot;71&quot;&gt;
                &lt;textblock Text=&quot;Brand: &quot;&gt;&lt;/TextBlock&gt;
                &lt;textblock Grid.Column=&quot;1&quot; Text=&quot;{Binding XPath=@Brand}&quot;&gt;&lt;/TextBlock&gt;
                &lt;textblock Grid.Row=&quot;1&quot; Text=&quot;Stock: &quot;&gt;&lt;/TextBlock&gt;
                &lt;textbox Grid.Row=&quot;1&quot; Grid.Column=&quot;1&quot; Text=&quot;{Binding XPath=Stock}&quot; /&gt;
            &lt;/StackPanel&gt;
        &lt;/StackPanel&gt;
       
    &lt;/Grid&gt;
&lt;/Window&gt;
&lt;/textarea&gt;


&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;
In this example i am loading main root elements i &lt;b&gt;combobox&lt;/b&gt;, based on the&lt;b&gt; combobox&lt;/b&gt; selection &lt;b&gt;ListView&lt;/b&gt; is loaded with the Model, Based on the selection in &lt;b&gt;ListView &lt;/b&gt;then &lt;b&gt;Brand&lt;/b&gt; Price details will be shown.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Watch this Video explaining &lt;a href=&quot;https://www.youtube.com/watch?v=1pVQ-VTcM18&quot; target=&quot;_blank&quot;&gt;How to Bind Xml Data to ListBox in WPF&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;480&quot; src=&quot;//www.youtube.com/embed/1pVQ-VTcM18&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://app.box.com/s/eitbmzv9t17o4r0hy6g1&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download SourceCode for More Clarification.&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I hope you got some basic details about &lt;b&gt;accessing xml data in wpf and bind it to UI.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and share it for our friends if you like this post. Thank You.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/1719604768748381333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/xml-data-binding-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1719604768748381333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1719604768748381333'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/xml-data-binding-wpf.html' title='Data Binding with WPF : Binding to XML'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-IXy4zLUPK0Y/UgyTmeFEjhI/AAAAAAAAA3Y/tMYukNTylTk/s72-c/XML+Data+Accessing.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-2799672404523662513</id><published>2013-08-15T19:21:00.000+05:30</published><updated>2015-01-17T01:00:22.568+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Binding in WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Data Binding in WPF with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article i will explain&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;What is data binding in wpf,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;What are the key components of binding,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How to bind an element as data source,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=fZozEqqrSDk&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to bind a Property as Source,&amp;nbsp;&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Binding an object as DataContext,&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Different Binding Modes in WPF etc. &lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://app.box.com/s/fen3fet3t7f31ulu99rv&quot; target=&quot;_blank&quot;&gt;Download SourceCode&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=V6wfWM21WRs&quot; target=&quot;_blank&quot;&gt;And Video Explaining Binding in WPF&lt;/a&gt;&amp;nbsp; &lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In the previous article i explained&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt; what is wpf and wpf basics&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;wpf architecture&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/WPF-vs-Windows-Forms-difference-between-wpf-windows-forms-in-events-properites-methods-for-control.html&quot; target=&quot;_blank&quot;&gt;Windows Forms Vs WPF&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/what-is-xaml-File-compilation-process-attribute-property-element-Syntaxes.html&quot; target=&quot;_blank&quot;&gt;what is xaml and xaml file compilation process&lt;/a&gt;,&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/04/basic-drawings-and-shapes-in-WPF-using-xaml-tags.html&quot; target=&quot;_blank&quot;&gt; Baisc Drawings and Shapes in wpf&lt;/a&gt; etc.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Data Binding in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/wpf-tutorials.html&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt;:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; One of the &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/wpf-tutorials.html&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt; Powerful feature is it&#39;s &lt;b&gt;Data Binding&lt;/b&gt; Concept. It is the process establishing connection between Application User Interface and Business Logic.&amp;nbsp; It requires a &lt;b&gt;Binding Source &lt;/b&gt;and &lt;b&gt;Target&lt;/b&gt; .&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-c4N3NdyF1CE/UgpAFyAhkkI/AAAAAAAAA0o/AZWxjUd0Ih8/s1600/Data+Binding.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Data Binding Architecture in WPF&quot; border=&quot;0&quot; height=&quot;139&quot; src=&quot;http://1.bp.blogspot.com/-c4N3NdyF1CE/UgpAFyAhkkI/AAAAAAAAA0o/AZWxjUd0Ih8/s640/Data+Binding.png&quot; title=&quot;Data Binding in wpf&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Establishing Binding in WPF&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; Source provides the data, and Target displays the data.&lt;/b&gt; &lt;b&gt;Data Binding Connects UI to Data&lt;/b&gt;. When Source Data values changed then UI is updated. This Updation depends upon the &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Different types of Data Binding Modes.&lt;/a&gt; These Data Binding&lt;b&gt; Decreases the code&lt;/b&gt; when compare to general binding. It also enables &lt;b&gt;Template Binding&lt;/b&gt; means we customize the data more precisely by specifying which property to bind to which control.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; So a &lt;b&gt;Binding &lt;/b&gt;Consists of 4 major Components:&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;Source&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Source Path&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Target Depenedency Object.&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Target Dependency Property.&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp;&amp;nbsp; Here &lt;b&gt;Target&lt;/b&gt; can be any Element or any 
accessible property that is derived from &lt;b&gt;Dependency Object&lt;/b&gt; for example
 TextBox controls Text Property is an &lt;b&gt;Dependency Property&lt;/b&gt;. If you see the &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;object hierarchy&lt;/a&gt; in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/wpf-tutorials.html&quot; target=&quot;_blank&quot;&gt;wpf &lt;/a&gt;almost all controls are derived from &lt;b&gt;Dependency Object.&lt;/b&gt; When coming 
to &lt;b&gt;Source,&lt;/b&gt; it can be any public property, CLR object, Ado.Net DataSet, 
XMLDataProvider, ObjectDataProvider etc.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-cAbYbewveDY/UgpAd4CfPbI/AAAAAAAAA0w/mlvE7Rt4_Pk/s1600/Data+Binding+Example.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;wpf binding in diagramatic format explanation&quot; border=&quot;0&quot; height=&quot;187&quot; src=&quot;http://3.bp.blogspot.com/-cAbYbewveDY/UgpAd4CfPbI/AAAAAAAAA0w/mlvE7Rt4_Pk/s640/Data+Binding+Example.png&quot; title=&quot;Simple wpf binding&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Binding a TextBox Text Property to a TextBlock Text Property&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&amp;nbsp;If you see the above image it gives you clear picture about data binding in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/wpf-tutorials.html&quot; target=&quot;_blank&quot;&gt;wpf.&lt;/a&gt; Here &lt;b&gt;Source&lt;/b&gt; is a TextBox, Text property of this textbox is bind to TextBlock Text Property. You can see the Code and&amp;nbsp; output below.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Element as Binding Source Example:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;5&quot;&gt; &lt;grid&gt;
        &lt;textbox Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;84,49,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textblock Height=&quot;61&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;82,78,0,0&quot; Name=&quot;textBlock1&quot; Text=&quot;{Binding ElementName=textBox1, Path=Text}&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;195&quot; /&gt;
    &lt;/Grid&gt;


&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Output is&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-C5ATmBP_pK0/UgpH2lHrwOI/AAAAAAAAA1A/AjjPS7p75zA/s1600/SImple+Binding.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;WPF Simple Binding example&quot; border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-C5ATmBP_pK0/UgpH2lHrwOI/AAAAAAAAA1A/AjjPS7p75zA/s1600/SImple+Binding.gif&quot; title=&quot;Simple binding example&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;WPF Simple binding&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
In the above example if you type any text in textbox then immeadiatly it is displayed in TextBlock. Upto now we saw &lt;b&gt;How to bind an element to another element,&lt;/b&gt; Now Let&#39;s see &lt;b&gt;how to bind properties to XAML elements.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; Now add a class to your project and name that as &lt;b&gt;MobileShop &lt;/b&gt;which consists of three properties &lt;b&gt;ShopOwner, Shop Number, and Address&lt;/b&gt; as below&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt;class MobileShop
    {
        public string ShopOwner { get; set; }
        public string ShopNumber { get; set; }
        public string  Address { get; set; }
    }

&lt;/textarea&gt;&lt;br /&gt;
Now add a new window to your project and drag three textboxes ,three labels for displaying above three properties.&lt;b&gt; XAML&lt;/b&gt; code looks like below.&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;14&quot;&gt;&lt;grid&gt;
        &lt;label Content=&quot;Shop Owner : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,51,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;87&quot; /&gt;
        &lt;label Content=&quot;Mobile Shop&quot; Height=&quot;38&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;68,0,0,0&quot; Name=&quot;label2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;130&quot; FontSize=&quot;20&quot; FontWeight=&quot;Bold&quot; /&gt;
        &lt;label Content=&quot;Shop Number : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,85,0,0&quot; Name=&quot;label3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;96&quot; /&gt;
        &lt;label Content=&quot;Shop Address:&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,119,0,0&quot; Name=&quot;label4&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;88&quot; /&gt;
// Binding ShopOwner Property
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopOwner}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,56,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;

// Binding ShopNumber Property 
       &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopNumber}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,87,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;

// Binding Address Property
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Address}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,119,0,0&quot; Name=&quot;textBox3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
    &lt;/Grid&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
Now in the Constructor of the Window write below code&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            // Creating an instance of MobileShop
            MobileShop ObjShop = new MobileShop();
            
            // Assigning values to properties

            ObjShop.ShopOwner = &quot;Sekhar Babu&quot;;
            ObjShop.ShopNumber = &quot;290&quot;;
            ObjShop.Address = &quot;Hyderabad&quot;;
            this.DataContext = ObjShop;
        }
        
    }

&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
As you may see that we have created an instance of class&lt;b&gt; MobileShop&lt;/b&gt; and assigned the data for properties.&lt;br /&gt;
After that we assigned the &lt;b&gt;object&lt;/b&gt; to&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt; DataContext Property&lt;/b&gt;&lt;/a&gt; of the Window. Here &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;DataContext&lt;/a&gt;&lt;b&gt; will hold the Data.&lt;/b&gt; This property exist for almost all controls that derived from &lt;b&gt;Dependency Object&lt;/b&gt; i.e Panel Controls like Grid, Canvas, StackPanel, Wrappanel, Content Controls like Label, Button&amp;nbsp; etc. If we set our object as &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;DataContext&lt;/a&gt; to a higher level control then all child controls can inherit that object. Read More About &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;DataContext in WPF&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So now in our present example we set object as &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;DataContext&lt;/a&gt; for window parent control&amp;nbsp; so all the child controls have default &lt;b&gt;data source&lt;/b&gt;, so we don&#39;t need to set &lt;b&gt;Source&lt;/b&gt; we just need to mention the &lt;b&gt;Path&lt;/b&gt; to which it binds. So in our example we only mentioned &lt;b&gt;Path&lt;/b&gt; as below.&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt;&lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopOwner}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,56,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopNumber}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,87,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Address}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,119,0,0&quot; Name=&quot;textBox3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;


&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
The same example can also be done without writing single peace of line code in code behind file, by writing only XAML code as below&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;window x:Class=&quot;WpfApplication1.Window1&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
       
        xmlns:local=&quot;clr-namespace:WpfApplication1&quot;
        Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;
    &lt;Window.DataContext&gt;
// We are setting Data Context Here
        &lt;local:MobileShop x:Name=&quot;MobileShopData&quot; ShopOwner=&quot;Sekhar Babu&quot; ShopNumber=&quot;290&quot; Address=&quot;Hyderabad&quot; /&gt;
    &lt;/Window.DataContext&gt;
        
    
    &lt;grid&gt;
        &lt;label Content=&quot;Shop Owner : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,51,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;87&quot; /&gt;
        &lt;label Content=&quot;Mobile Shop&quot; Height=&quot;38&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;68,0,0,0&quot; Name=&quot;label2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;130&quot; FontSize=&quot;20&quot; FontWeight=&quot;Bold&quot; /&gt;
        &lt;label Content=&quot;Shop Number : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,85,0,0&quot; Name=&quot;label3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;96&quot; /&gt;
        &lt;label Content=&quot;Shop Address:&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,119,0,0&quot; Name=&quot;label4&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;88&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopOwner}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,56,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopNumber}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,87,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Address}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,119,0,0&quot; Name=&quot;textBox3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
    &lt;/Grid&gt;
&lt;/Window&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
Here first we have to set the namespace reference to access class files in the same project. i.e&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;xmlns:local=&quot;clr-namespace:WpfApplication1&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now we can access all contents in the project using local reference like below.&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt; 
&lt;Window.DataContext&gt;
        &lt;local:MobileShop x:Name=&quot;MobileShopData&quot; ShopOwner=&quot;Sekhar Babu&quot; ShopNumber=&quot;290&quot; Address=&quot;Hyderabad&quot; /&gt;
    &lt;/Window.DataContext&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Binding in Code behind file:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;We can also perform data binding in code file.&amp;nbsp;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;Create the Binding Object&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Set the Binding Source&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Set the path&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Bind the object to Target using SetBinding Method.&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
Here is an example on &lt;b&gt;how to perform binding in code behind file.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;// Creating an instance of MobileShop
            MobileShop ObjShop = new MobileShop();

            // Assigning values to properties

            ObjShop.ShopOwner = &quot;Sekhar Babu&quot;;
            ObjShop.ShopNumber = &quot;290&quot;;
            ObjShop.Address = &quot;Hyderabad&quot;;

            Binding be1 = new Binding(&quot;ShopOwner&quot;);
            be1.Source = ObjShop;
            txtShopOwner.SetBinding(TextBox.TextProperty, be1);
            Binding be2 = new Binding(&quot;ShopNumber&quot;);
            be2.Source = ObjShop;
            txtShopNumber.SetBinding(TextBox.TextProperty, be2);
            Binding be3 = new Binding(&quot;Address&quot;);
            be3.Source = ObjShop;
            txtAddress.SetBinding(TextBox.TextProperty, be3);


&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Binding Modes in WPF:&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;Mode&lt;/b&gt; is the one property of the &lt;b&gt;binding element&lt;/b&gt; which determines the flow of data between binding source and target. Four &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Binding Modes&lt;/a&gt; available.&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;OneWay.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OneTime.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OneWayToSource.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;TwoWay. &lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;OneWay:&amp;nbsp;&lt;/b&gt; If &lt;b&gt;Mode&lt;/b&gt; is &lt;b&gt;OneWay&lt;/b&gt; means&lt;b&gt; Data flows from source to target whenever source is changed.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-OGa-BRotk0k/UgzFJkOtveI/AAAAAAAAA3o/fNMQIbhUJk8/s1600/One+Way+Binding.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;OneWay Binding Mode Image&quot; border=&quot;0&quot; height=&quot;132&quot; src=&quot;http://1.bp.blogspot.com/-OGa-BRotk0k/UgzFJkOtveI/AAAAAAAAA3o/fNMQIbhUJk8/s640/One+Way+Binding.png&quot; title=&quot;OneWay Binding Mode in wpf&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;OneWay Binding Mode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Here &lt;b&gt;Target UI will be updated only if the source changed&lt;/b&gt;. Use this to display read only data in the UI.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OneTime:&amp;nbsp; &lt;/b&gt;If the &lt;b&gt;Mode&lt;/b&gt; is &lt;b&gt;OneTime&lt;/b&gt; then &lt;b&gt;data flows from source to target when application starts or &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;datacontext &lt;/a&gt;changes.&lt;/b&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-_EFlmPVvVxE/UgzGPQyV_dI/AAAAAAAAA34/SguOLzDvQNE/s1600/One+Time+Binding+Mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;OneTime Binding Mode&quot; border=&quot;0&quot; height=&quot;138&quot; src=&quot;http://2.bp.blogspot.com/-_EFlmPVvVxE/UgzGPQyV_dI/AAAAAAAAA34/SguOLzDvQNE/s640/One+Time+Binding+Mode.png&quot; title=&quot;OneTime Binding Mode in WPF&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;OneTime Binding Mode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp;&amp;nbsp; You can use this to show read only data. This can be used to &lt;b&gt;compare the changes occurred in UI.&lt;/b&gt; This &lt;b&gt;Mode&lt;/b&gt; very useful source doesn&#39;t implement &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/INotifyPropertyChanged-in-wpf.html&quot; target=&quot;_blank&quot;&gt;INotifyPropertyChanged&lt;/a&gt; Interface.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OneWayToSource: &lt;/b&gt;This is completely opposite to &lt;b&gt;OneWay&lt;/b&gt; mode. In this &lt;b&gt;Mode if target UI value is changed by user then it is updated in the source&lt;/b&gt; if the source is&lt;b&gt; dependency property&lt;/b&gt; or it is implemented by&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/INotifyPropertyChanged-in-wpf.html&quot; target=&quot;_blank&quot;&gt; INotifyPropertyChanged &lt;/a&gt;Interface.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-1P-FHoQULm0/UgzIQEVYFSI/AAAAAAAAA4I/d0NHA-hskh8/s1600/OneWayToSource+Binding+Mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;OneWayToSource Binding&quot; border=&quot;0&quot; height=&quot;130&quot; src=&quot;http://4.bp.blogspot.com/-1P-FHoQULm0/UgzIQEVYFSI/AAAAAAAAA4I/d0NHA-hskh8/s640/OneWayToSource+Binding+Mode.png&quot; title=&quot;OneWayToSource Binding Mode&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;OneWayToSource Binding Mode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp;&amp;nbsp; In this case&lt;b&gt; target is not updated if source is updated because of changes occurred in target.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;TwoWay:&lt;/b&gt;&amp;nbsp; If the &lt;b&gt;Mode&lt;/b&gt; is &lt;b&gt;TwoWay&lt;/b&gt; then &lt;b&gt;Whenever the Source is updated then target is updated, in the same manner if the target value is changed by user then Source is updated with target value and If the binding Source is bind to multiple targets&amp;nbsp; then all the targets are updated with Source data.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-nYdW0R1hjBg/UgzK7R2-62I/AAAAAAAAA4Y/rbwawD7LcsA/s1600/Two+Way+Binding+Mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;TwoWay Binding Example&quot; border=&quot;0&quot; height=&quot;138&quot; src=&quot;http://1.bp.blogspot.com/-nYdW0R1hjBg/UgzK7R2-62I/AAAAAAAAA4Y/rbwawD7LcsA/s640/Two+Way+Binding+Mode.png&quot; title=&quot;TwoWay Binding Mode in WPF&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;TwoWay Binding Mode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Use this Mode when User can change binding source and all it&#39;s targets.&lt;br /&gt;
For Understanding &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Binding Modes&lt;/a&gt;&amp;nbsp; briefly read this &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Binding Modes in WPF with example&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;We have seen Binding Source is updated in &lt;b&gt;OneWayToSource&lt;/b&gt; and &lt;b&gt;TwoWay&lt;/b&gt; &lt;b&gt;Binding Modes&lt;/b&gt;. More Precisely we can control the binding source updation by using &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;UpdateSourceTrigger&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
UpdateSourceTrigger in WPF:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger&lt;/a&gt; is one of the property of Binding class. This Property defines the timing of binding source updation. This Property has three Options available. These are&amp;nbsp;&lt;b&gt; LostFocus, PropertyChanged, Explicit.&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Suppose you bind a property to a textbox, then if &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger&lt;/a&gt; is set to &lt;b&gt;LostFocus &lt;/b&gt;then all the changes occurred in the textbox is updated in the source when TextBox Lost focus. If &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger&lt;/a&gt; is set to &lt;b&gt;PropertyChanged &lt;/b&gt;then binding source is updated for every change in target. and if the &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger&lt;/a&gt; is &lt;b&gt;Explicit &lt;/b&gt;then binding source is updated only when we explicitly called &lt;b&gt;UpdateSource ( )&lt;/b&gt; method.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
For More Explanation about &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger&lt;/a&gt; Read this &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger in WPF Tutorial.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Watch the &lt;a href=&quot;https://www.youtube.com/watch?v=V6wfWM21WRs&quot; target=&quot;_blank&quot;&gt;Video Explaining Binding in WPF&lt;/a&gt; &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;480&quot; src=&quot;//www.youtube.com/embed/V6wfWM21WRs?list=PLqgHgAbXizm6u5wSO4DrCiMSldIk3xhMN&quot; width=&quot;853&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; I hope now you will able to &lt;b&gt;work with wpf bindings&lt;/b&gt;. &lt;a href=&quot;https://app.box.com/s/fen3fet3t7f31ulu99rv&quot; target=&quot;_blank&quot;&gt;Download the Source Code&lt;/a&gt; and watch the Video about Bindings in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/wpf-tutorials.html&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt;. Let me know if you need any clarification.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and share for our friends if you like this post.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/2799672404523662513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/binding-in-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2799672404523662513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2799672404523662513'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/binding-in-wpf.html' title='Data Binding in WPF with Example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-c4N3NdyF1CE/UgpAFyAhkkI/AAAAAAAAA0o/AZWxjUd0Ih8/s72-c/Data+Binding.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-3412127455342387101</id><published>2013-08-14T19:36:00.001+05:30</published><updated>2015-01-17T01:00:51.250+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Binding in WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>INotifyPropertyChanged Interface in WPF with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article i will explain&lt;b&gt; how to Create INotifyPropertyChanged Interface in Class file, How to Implement it for Binding in wpf.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;https://app.box.com/s/45lz9bfd1gyg8w4z7edq&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download SourceCode&lt;/a&gt; &lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&amp;nbsp; INotifyPropertyChanged Interface&lt;/b&gt; defined in&lt;b&gt; System.ComponentModel &lt;/b&gt;Class. It has an &lt;b&gt;event Handler&lt;/b&gt; called &lt;b&gt;PropertyChangedEventHandler&lt;/b&gt; which can be used to create an Event that can be used to &lt;b&gt;notify the changes occured in Properties.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
For example i had a class called MobileStore with Four Properties i.e Brand, Mode, Stock, Price. We can implement&lt;b&gt; INotifyPropertyChanged interface&lt;/b&gt; for that class as follows.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt; class MobileStore:INotifyPropertyChanged
    {
        public string _Brand;
        public string _Model;
        public int _Stock;
        public double _Price;

        public string Brand
        {
            get { return _Brand; }
            set { 
                _Brand = value; 
                OnPropertyChanged(&quot;Brand&quot;);
            } 
        }
        public string Model 
        {
            get { return _Model; } 
            set { 
                _Model = value; 
                OnPropertyChanged(&quot;Model&quot;); 
            } 
        }
        public int Stock 
        { 
            get { return _Stock; } 
            set { 
                _Stock = value; 
                OnPropertyChanged(&quot;Stock&quot;); 
            } 
        }
        public double Price 
        { 
            get { return _Price; } 
            set { 
                _Price = value; 
                OnPropertyChanged(&quot;Price&quot;); 
            } 
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string Property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(Property));
            }
        }
    }

&lt;/textarea&gt;


&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Using INotifyPropertyChanged in Binding :&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In &lt;b&gt;WPF Binding&lt;/b&gt; &lt;b&gt;Target&lt;/b&gt; must be &lt;b&gt;Dependency Property&lt;/b&gt; and &lt;b&gt;Source &lt;/b&gt;can be &lt;b&gt;Dependency Property&lt;/b&gt; or &lt;b&gt;an CLR object&lt;/b&gt; or other. Here&lt;b&gt; Dependency Property&lt;/b&gt; has &lt;b&gt;built-in Notification feature.&lt;/b&gt; So if the &lt;b&gt;Source&lt;/b&gt; is an &lt;b&gt;CLR Object &lt;/b&gt;or other then we need take care about changes notification to target. In that case we have to use &lt;b&gt;INotifyPropertyChanged Interface to notify the bindings that source property is changed you need to update the UI with new data.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here is an Example using Above &lt;b&gt;MobileShop&lt;/b&gt; class and its properties. The four Properties of &lt;b&gt;MobileShop&lt;/b&gt; class are bind to textboxes.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
XAML Code:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;window x:Class=&quot;INotifyProperty.MainWindow&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:local=&quot;clr-namespace:INotifyProperty&quot;
        Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot;&gt;
    &lt;Window.Resources&gt;
        &lt;local:MobileStore x:Key=&quot;MobileStoreData&quot; Brand=&quot;Nokia&quot; Model=&quot;1196&quot; Stock=&quot;129&quot; Price=&quot;23000&quot;/&gt;
    &lt;/Window.Resources&gt;
    &lt;grid DataContext=&quot;{StaticResource MobileStoreData}&quot;&gt;
        &lt;label Content=&quot;MobileStore&quot; FontWeight=&quot;Bold&quot; FontSize=&quot;20&quot; Height=&quot;43&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;171,12,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;127&quot; /&gt;
        &lt;label Content=&quot;Brand : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;66,79,0,0&quot; Name=&quot;label2&quot; VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot; FontSize=&quot;12&quot; /&gt;
        &lt;label Content=&quot;Model : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;66,114,0,0&quot; Name=&quot;label3&quot; VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot; FontSize=&quot;12&quot; /&gt;
        &lt;label Content=&quot;Stock : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;66,149,0,0&quot; Name=&quot;label4&quot; VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot; FontSize=&quot;12&quot; /&gt;
        &lt;label Content=&quot;Price : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;66,185,0,0&quot; Name=&quot;label5&quot; VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot; FontSize=&quot;12&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Brand}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;138,82,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;173&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Model}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;138,116,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;173&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Stock}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;138,150,0,0&quot; Name=&quot;textBox3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;173&quot; /&gt;
        &lt;textbox Height=&quot;23&quot;  Text=&quot;{Binding Path=Price}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;138,184,0,0&quot; Name=&quot;textBox4&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;173&quot; /&gt;
    &lt;/Grid&gt;
&lt;/Window&gt;




&lt;/textarea&gt;


&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I hope you got simple knowledge about&lt;b&gt; How to implement INotifyPropertyChanged Interface for a Class and How to use it wpf binding.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and Share if you like this post for our friends. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/3412127455342387101/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/INotifyPropertyChanged-in-wpf.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3412127455342387101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3412127455342387101'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/INotifyPropertyChanged-in-wpf.html' title='INotifyPropertyChanged Interface in WPF with Example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-3690665070160452407</id><published>2013-08-14T17:12:00.000+05:30</published><updated>2015-01-17T01:01:17.657+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Binding in WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>DataContext in WPF with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In this article i will explain&amp;nbsp;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;What is DataContext in WPF? and How to Bind Objects to DataContext.&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;&amp;nbsp;How DataContext helpful to WPF binding Techniques. &lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://app.box.com/s/0bqao96b2ho3824ye7n4&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Download Source Code&lt;/b&gt;&lt;/a&gt;&lt;b&gt; And &lt;a href=&quot;http://youtu.be/Z2usZJGQxSA&quot; target=&quot;_blank&quot;&gt;Video Explaining about DataContext Property in WPF&amp;nbsp;&lt;/a&gt;&lt;/b&gt; &lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
DataContext:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;b&gt; DataContext&lt;/b&gt; is the &lt;b&gt;Dependency Property which holds the Data&lt;/b&gt;. Here Data can be any type, it can be an &lt;b&gt;CLR Object, a DataSet, XMLDataProvider, Any Collection Object&lt;/b&gt; etc. Almost all controls in wpf &lt;b&gt;user interfaces&lt;/b&gt; are derived from &lt;b&gt;Dependency Object&lt;/b&gt; so either &lt;b&gt;Panel controls&lt;/b&gt; or &lt;b&gt;Content Controls&lt;/b&gt; can have this Property.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This &lt;b&gt;Dependency Property&lt;/b&gt; has&lt;b&gt; &quot;Value Inheritance &quot;&lt;/b&gt; feature means &lt;b&gt;if you set Data Context as Data Object on Parent element then all of its descendent elements or children elements can reference to Data assigned to parent DataContext. i.e&amp;nbsp; All the child elements are bind against to the Data Object of parent control DataContext unless if we specify to bind against to other Objects.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If &lt;b&gt;DataContext&lt;/b&gt; is set on parent elements then no need to set binding source to children elements , we need to specify the path only for children elements. Let us see with example.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I have class called &lt;b&gt;MobileShop&lt;/b&gt; with three properties.&lt;/div&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt; class MobileShop
    {
        public string ShopOwner { get; set; }
        public string ShopNumber { get; set; }
        public string  Address { get; set; }
    }
&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now i will show these three properties in three textboxes by setting MobileShop Object as DataContext for Window&lt;br /&gt;
&lt;br /&gt;
Here is the &lt;b&gt;XAML Code&lt;/b&gt; How the Window Looks like and&lt;b&gt; How Child Elements access the DataContext of the Parent Control.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;window x:Class=&quot;WpfApplication1.Window1&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
       
        xmlns:local=&quot;clr-namespace:WpfApplication1&quot;
        Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;
    &lt;Window.DataContext&gt;
        &lt;local:MobileShop x:Name=&quot;MobileShopData&quot; ShopOwner=&quot;Sekhar Babu&quot; ShopNumber=&quot;290&quot; Address=&quot;Hyderabad&quot; /&gt;
    &lt;/Window.DataContext&gt;
    &lt;grid&gt;
        &lt;label Content=&quot;Shop Owner : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,51,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;87&quot; /&gt;
        &lt;label Content=&quot;Mobile Shop&quot; Height=&quot;38&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;68,0,0,0&quot; Name=&quot;label2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;130&quot; FontSize=&quot;20&quot; FontWeight=&quot;Bold&quot; /&gt;
        &lt;label Content=&quot;Shop Number : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,85,0,0&quot; Name=&quot;label3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;96&quot; /&gt;
        &lt;label Content=&quot;Shop Address:&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,119,0,0&quot; Name=&quot;label4&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;88&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopOwner}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,56,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopNumber}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,87,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Address}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,119,0,0&quot; Name=&quot;textBox3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
    &lt;/Grid&gt;
&lt;/Window&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
If you see the above xaml code for accessing the local class file in XAML code first i created a namespace reference to local as below&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;xmlns:local=&quot;clr-namespace:WpfApplication1&quot;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Now &lt;/b&gt;&lt;span style=&quot;color: black;&quot;&gt;we can able to access project resources using local reference in XAML code like below&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;5&quot;&gt;    &lt;Window.DataContext&gt;
        &lt;local:MobileShop x:Name=&quot;MobileShopData&quot; ShopOwner=&quot;Sekhar Babu&quot; ShopNumber=&quot;290&quot; Address=&quot;Hyderabad&quot; /&gt;
    &lt;/Window.DataContext&gt;
&lt;/textarea&gt; 
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;In the above lines i created an instance of &lt;b&gt;MobileShop&lt;/b&gt; Class added data to properties and assigned that object as DataContext for Window Element. So for all the child elements we have to set the path only no need to set source again.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Source Vs DataContext:&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; There is a situation where &lt;b&gt;parent element is set to DataContext object and Child Element bind to Source of another Object then Child Element binds to Source Object Only. &lt;/b&gt;Here child element checks first if any &lt;b&gt;Source or RelativeSource&lt;/b&gt; bind to any object, if set&amp;nbsp; it will bind to that object, if Source or RelativeSource is not set then WPF &lt;b&gt;Searches up in the element tree for DataContext of the Parent elements if it finds any non null Object then that objects used for Binding&lt;/b&gt;. This type of Binding use full when multiple properties are &lt;b&gt;bind to Single Source.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Here is one example using same MobileShop class , where we will create two objects for this class and one object will bind to parent element as earlier, another bind to child element directly as source.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;20&quot;&gt;&lt;window x:Class=&quot;WpfApplication1.Window2&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;         
        xmlns:local=&quot;clr-namespace:WpfApplication1&quot;
        Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;
    &lt;Window.Resources&gt;
        &lt;local:MobileShop x:Key=&quot;MobileShopData1&quot; ShopOwner=&quot;Sekhar Babu&quot; ShopNumber=&quot;290&quot; Address=&quot;Hyderabad&quot; /&gt;
        &lt;local:MobileShop x:Key=&quot;MobileShopData2&quot; ShopOwner=&quot;Mani Sharma&quot; ShopNumber=&quot;312&quot; Address=&quot;AndhraPradesh&quot; /&gt;
    &lt;/Window.Resources&gt;
    &lt;grid DataContext=&quot;{StaticResource MobileShopData1}&quot;&gt;
        &lt;label Content=&quot;Shop Owner : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,51,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;87&quot; /&gt;
        &lt;label Content=&quot;Mobile Shop&quot; Height=&quot;38&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;68,0,0,0&quot; Name=&quot;label2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;130&quot; FontSize=&quot;20&quot; FontWeight=&quot;Bold&quot; /&gt;
        &lt;label Content=&quot;Shop Number : &quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,85,0,0&quot; Name=&quot;label3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;96&quot; /&gt;
        &lt;label Content=&quot;Shop Address:&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,119,0,0&quot; Name=&quot;label4&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;88&quot; /&gt;
       &lt;!--Directly Setting Source to child element, So Child will bind to MobileShopData2 Object--&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Source={StaticResource MobileShopData2}, Path=ShopOwner}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,56,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
       &lt;!--These two textboxes bind to DataContext of the Grid i.e MobileShopData1 Object--&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=ShopNumber}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,87,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding Path=Address}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;118,119,0,0&quot; Name=&quot;textBox3&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
    &lt;/Grid&gt;    
&lt;/Window&gt;
&lt;/textarea&gt;


&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Conclusion:&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In this way &lt;b&gt;DataContext Property is useful when setting multiple properties to Single Source.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you are binding single property then it is better to set as source for the element because of easy debugging i.e all the binding information exist in one place rather than searching up in the element tree for nearest &lt;b&gt;DataContext. &lt;/b&gt;This &lt;b&gt;DataContext&lt;/b&gt; defined in&lt;b&gt; FrameworkElement &lt;/b&gt;Class.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Don&#39;t forget to Comment and Share to our friends if you like this post. Thank You.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/3690665070160452407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/DataContext-in-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3690665070160452407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3690665070160452407'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/DataContext-in-wpf.html' title='DataContext in WPF with Example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-6676064501784007233</id><published>2013-08-14T16:44:00.000+05:30</published><updated>2015-01-17T01:01:43.598+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Binding in WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>WPF Tutorials</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
WPF Tutorials and How to Examples &lt;/h2&gt;
Hi, this page contains &lt;b&gt;the WPF Tutorials and How to examples Concept &lt;/b&gt;wise, i will update the &lt;b&gt;WPF&lt;/b&gt; tutorials whenever updated.If you are new to &lt;b&gt;WPF&lt;/b&gt; you can go through them in sequential order so that you can learn &lt;b&gt;wpf from basics.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;WPF Tutorials- Windows Presentation Foundation&lt;/b&gt;&lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;WPF Basics:&lt;/b&gt;&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt;What is WPF and Features of WPF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/WPF-vs-Windows-Forms-difference-between-wpf-windows-forms-in-events-properites-methods-for-control.html&quot; target=&quot;_blank&quot;&gt;Windows Forms Vs WPF.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;Architecture of WPF and Object Hierarchy Of WPF Controls.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
XAML Basics:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/what-is-xaml-File-compilation-process-attribute-property-element-Syntaxes.html&quot; target=&quot;_blank&quot;&gt;What is XAML and XAML File Compilation Process.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/Tutorial-Markup-Extensions-XAML-based-and-WPF-based-example-binding-Csharp.Net.html&quot; target=&quot;_blank&quot;&gt;WPF Markup Extensions and Usage.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Data Binding in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Binding in WPF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;Different Binding Modes in WPF with Example.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;DataContext Property Usage in WPF.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/INotifyPropertyChanged-in-wpf.html&quot; target=&quot;_blank&quot;&gt;How to Implement INotifyPropertyChanged Interface in WPF.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger Property Usage in WPF.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=1pVQ-VTcM18&quot; target=&quot;_blank&quot;&gt;XmlDataProvider Class Usage for Binding XmlData.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=Yt0_5nHymO0&quot; target=&quot;_blank&quot;&gt;How to Bind Xml Data to DataGrid in WPF. &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
MVVM Model(Model -View-View-Model): &lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Layout Controls in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Overview of WPF Layout Controls.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Grid Layout Control in WPF.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Canvas Layout Control in WPF.&lt;/li&gt;
&lt;li&gt;StackPanel Layout Control in WPF.&lt;/li&gt;
&lt;li&gt;DockPanel Layout Control in WPF.&lt;/li&gt;
&lt;li&gt;WrapPanel Layout Control in WPF.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
WPF DataBindings:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Different Types of DataBinding Mode in WPF.&lt;/li&gt;
&lt;li&gt;AttachedProperty in WPF.&lt;/li&gt;
&lt;li&gt;Dependency Property in WPF.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;INotifyPropertyChanged Interface in WPF.&lt;/li&gt;
&lt;li&gt;ValueConverters in WPF.&lt;/li&gt;
&lt;li&gt;DataContext Property in WPF.&lt;/li&gt;
&lt;li&gt;UpdateSourceTrigger in WPF.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Controls in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;ListView Control in WPF and Usage.&lt;/li&gt;
&lt;li&gt;DataGrid Control in WPF and Usage. &lt;/li&gt;
&lt;li&gt;MediaElement Control in WPF and Usage.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Brushes in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;SolidColorBrush in WPF and Usage.&lt;/li&gt;
&lt;li&gt;LinearGradientBrush in WPF  and Usage. &lt;/li&gt;
&lt;li&gt;RadialGradientBrush in WPF and Usage. &lt;/li&gt;
&lt;li&gt;ImageBrush in WPF and Usage.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Transformations in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Rotate Transformation in WPF&lt;/li&gt;
&lt;li&gt;Skew Transformation in WPF&lt;/li&gt;
&lt;li&gt;Scale Transformation in WPF.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Translate Transform.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
2D Drawings and Shapes in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/04/basic-drawings-and-shapes-in-WPF-using-xaml-tags.html&quot; target=&quot;_blank&quot;&gt;Basic Drawings and Shapes in WPF.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;How to Examples&lt;/b&gt;&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/wpf-animation-move-an-element-line-from-top-to-bottom-using-doubleanimation.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to move a line from top to bottom using wpf doubleanimation. &lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Routed Events in WPF:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Triggers in WPF:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Event Triggers in WPF&lt;/li&gt;
&lt;li&gt;Property Triggers in WPF&lt;/li&gt;
&lt;li&gt;Data Triggers in WPF &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Styles and Resources in WPF:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Animations in WPF:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
WPF Interoperability:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
WPF UserControl:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Speech Synthesis in WPF: &lt;/h3&gt;
&lt;div&gt;
Keep visiting this page i will update it everyday with new posts. Thank You.&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/6676064501784007233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/wpf-tutorials.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/6676064501784007233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/6676064501784007233'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/wpf-tutorials.html' title='WPF Tutorials'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-6528210642714715589</id><published>2013-08-14T13:26:00.000+05:30</published><updated>2015-01-17T01:02:10.848+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Binding in WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="UpdateSourceTrigger"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>UpdateSourceTrigger Property in WPF Binding Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In this article i will explain&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;What is the purpose of UpdateSourceTrigger Property,&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&amp;nbsp;How to use UpdateSourceTrigger Property in WPF Binding,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;What are the different Options available for UpdateSourceTrigger Property&lt;/b&gt; etc.&lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp; &lt;a href=&quot;https://app.box.com/s/tw392tshzwbln1kf0ei0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download Source Code And&lt;/a&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=4lw95lkfQW0&quot; target=&quot;_blank&quot;&gt;Video Explanation of UpdateSourceTriggerUsage&lt;/a&gt; &lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; UpdateSourceTrigger&lt;/b&gt; is the one of the Property of Binding element in WPF. This Property defines the&lt;b&gt; timing of binding source updates.&lt;/b&gt; There are two &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;binding modes&lt;/b&gt;&lt;/a&gt; which &lt;b&gt;updates the source i.e &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;OneWayToSource and TwoWay.&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-HcFeLvw43cE/UgsPbSVUcJI/AAAAAAAAA3E/zugiFEOD_cI/s1600/UpdateSourceTrigger+in+Binding.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;UpdateSourceTrigger Property Required Modes&quot; border=&quot;0&quot; height=&quot;150&quot; src=&quot;http://1.bp.blogspot.com/-HcFeLvw43cE/UgsPbSVUcJI/AAAAAAAAA3E/zugiFEOD_cI/s640/UpdateSourceTrigger+in+Binding.png&quot; title=&quot;UpdateSourceTrigger Property Usage&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So in this &lt;b&gt;Two Modes&lt;/b&gt; we need specify when should occur the&lt;b&gt; binding source updation.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;UpdateSourceTrigger&lt;/b&gt; Property has three properties.&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;LostFocus&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;PropertyChanged&lt;/b&gt;&lt;/li&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;li&gt;&lt;b&gt;Explicit.&lt;/b&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
To understand this with example, add new window to wpf project and add new window which contains&amp;nbsp; a ListBox with List of colors and textbox whose Text, Background properties are bind to ListBox.SelectedItem.Content Property.&lt;br /&gt;
&lt;br /&gt;
XAML Code is:&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;&lt;grid&gt;
        &lt;label Content=&quot;Colors&quot; FontSize=&quot;20&quot; FontWeight=&quot;Bold&quot; Height=&quot;37&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;10,10,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;85&quot; /&gt;
        &lt;listbox Height=&quot;99&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;18,53,0,0&quot; Name=&quot;listColors&quot; SelectedIndex=&quot;0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;149&quot;&gt;
            &lt;listboxitem Content=&quot;Black&quot; /&gt;
            &lt;listboxitem Content=&quot;Blue&quot; /&gt;
            &lt;listboxitem Content=&quot;Green&quot; /&gt;
            &lt;listboxitem Content=&quot;Yellow&quot; /&gt;
            &lt;listboxitem Content=&quot;Olive&quot; /&gt;
            &lt;listboxitem Content=&quot;Pink&quot; /&gt;
        &lt;/ListBox&gt;
        &lt;textbox Background=&quot;{Binding ElementName=listColors, Path=SelectedItem.Content, Mode=TwoWay, UpdateSourceTrigger=LostFocus}&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;21,169,0,0&quot; Name=&quot;textBox1&quot; Text=&quot;{Binding ElementName=listColors, Path=SelectedItem.Content, Mode=TwoWay,UpdateSourceTrigger=LostFocus}&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;238&quot; /&gt;
    &lt;/Grid&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;LostFocus:&lt;/b&gt;&amp;nbsp; If set, &lt;b&gt;Binding Source will be updated when target control lost foucs. &lt;/b&gt;Now run the above example type one color in textbox and press tab you will notice that listbox is changed and Textbox background is changed.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;PropertyChanged:&lt;/b&gt; If &lt;b&gt;UpdateSourceTrigger Property&lt;/b&gt; is set to &lt;b&gt;PropertyChanged&lt;/b&gt;, then &lt;b&gt;source is updated with target data whenever change occurs in Target.&lt;/b&gt; Now Change UpdateSourceTrigger Property in our example to PropertyChanged. Now run the example and type in textbox, then ListBox is updated with this content.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Explicit:&amp;nbsp; &lt;/b&gt;If&lt;b&gt; UpdateSourceTrigger&lt;/b&gt; Property is set to&lt;b&gt; Explicit&lt;/b&gt;, then &lt;b&gt;Binding source is updated only when BindingExpression.UpdateSource( ) method is called externally&lt;/b&gt;. Now in our example set the UpdateSourceTrigger Property to Explicitly and add a button to window. Now in button click write below code.&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;5&quot;&gt;// Replate it with your textbox name
            BindingExpression ObjBe = textBox1.GetBindingExpression(TextBox.TextProperty);
            ObjBe.UpdateSource();
&lt;/textarea&gt;

&lt;br /&gt;
&lt;br /&gt;
Now run our example and type one color in textbox and then click the button. Now the ListBox is updated with this data instead updating while typing or lost focus.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Default: &lt;/b&gt;Instead of these three options, &lt;b&gt;Default&lt;/b&gt; option exist which will&lt;b&gt; take place when we didn&#39;t specify any option in UpdateSourceTrigger Property.&lt;/b&gt; This Default option takes any of three options &lt;b&gt;based on the Dependency Property of Target Control.&lt;/b&gt; For example Text Property of TextBox control has default option is &lt;b&gt;LostFocus.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;For More Graphical explanation Watch the Video Explaining the UpdateSourceTrigger Property &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/4lw95lkfQW0&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I hope you are clear about &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to use UpdateSourceTrigger Property in wpf bindings.&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Don&#39;t Forget to Comment and Share for our friends if you like this post. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/6528210642714715589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/updatesourcetrigger-property-in-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/6528210642714715589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/6528210642714715589'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/updatesourcetrigger-property-in-wpf.html' title='UpdateSourceTrigger Property in WPF Binding Example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-HcFeLvw43cE/UgsPbSVUcJI/AAAAAAAAA3E/zugiFEOD_cI/s72-c/UpdateSourceTrigger+in+Binding.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4982678700685000248</id><published>2013-08-14T09:56:00.000+05:30</published><updated>2015-01-17T01:02:46.606+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Binding Modes"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'> Binding Modes in WPF with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In this article will see &lt;b&gt;purpose of Mode property in Data Binding, What are the different Data Binding Modes available in WPF, When to use each of these binding modes&lt;/b&gt; etc.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;Mode&lt;/b&gt; is the one of the property of the &lt;b&gt;Binding&lt;/b&gt; Element. &lt;b&gt;Mode&lt;/b&gt; attribute defines the &lt;b&gt;Data Binding Mode which determines how data flows between source and target.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;480&quot; src=&quot;//www.youtube.com/embed/L9NiB7ptJSw&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Four Types of Data Binding Modes available.&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;OneWay&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OneTime&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OneWayToSource&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;TwoWay&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
For understanding &lt;b&gt;Binding Modes&lt;/b&gt; briefly let us take an example which contains a ListBox, a TextBlock, a TextBox. ListBox contains List of Colors, Selected value of ListBox is binded to Background and Text dependency properties of TextBlock, and Text property of TextBox.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;XAML Code &lt;/b&gt;Looks like below.&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;10&quot;&gt;&lt;grid&gt;
        &lt;label Content=&quot;Colors&quot; FontWeight=&quot;Bold&quot; FontSize=&quot;20&quot; Height=&quot;37&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;26,3,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;85&quot; /&gt;
        &lt;listbox Height=&quot;99&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;34,46,0,0&quot; Name=&quot;listColors&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;149&quot;&gt;
            &lt;listboxitem Content=&quot;Black&quot; /&gt;
            &lt;listboxitem Content=&quot;Blue&quot; /&gt;
            &lt;listboxitem Content=&quot;Green&quot; /&gt;
            &lt;listboxitem Content=&quot;Yellow&quot; /&gt;
            &lt;listboxitem Content=&quot;Olive&quot; /&gt;
            &lt;listboxitem Content=&quot;Pink&quot; /&gt;
        &lt;/ListBox&gt;
        &lt;textblock Height=&quot;23&quot; Text=&quot;{Binding ElementName=listColors, Path=SelectedItem.Content, Mode=OneWay}&quot;  Background=&quot;{Binding ElementName=listColors, Path=SelectedItem.Content,Mode=OneWay}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;35,158,0,0&quot; Name=&quot;textBlock1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;240&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; Text=&quot;{Binding ElementName=listColors, Path=SelectedItem.Content,Mode=OneWay}&quot;  Background=&quot;{Binding ElementName=listColors, Path=SelectedItem.Content,Mode=OneWay}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;37,190,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;238&quot; /&gt;
    &lt;/Grid&gt;



&lt;/textarea&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
OneWay:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Binding&lt;b&gt; Mode&lt;/b&gt; is &lt;b&gt;OneWay&lt;/b&gt; means whenever the &lt;b&gt;Source Data&lt;/b&gt; is changed then that data is reflected in Target UI. Suppose in the above example we binded the listbox&#39;s&amp;nbsp; &lt;b&gt;SelectedValue.Content&lt;/b&gt; to TextBox and TextBlock&#39;s Background and Text Properties. So whenever we select another ListBoxItem then that value is Update in Target i.e in TextBox and TextBlock.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-cMza8K9B9iA/Ugr1WoDDcqI/AAAAAAAAA1Q/UUZRqSzlN64/s1600/One+Way+Binding.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;OneWay Binding Mode in WPF&quot; border=&quot;0&quot; height=&quot;133&quot; src=&quot;http://3.bp.blogspot.com/-cMza8K9B9iA/Ugr1WoDDcqI/AAAAAAAAA1Q/UUZRqSzlN64/s640/One+Way+Binding.png&quot; title=&quot;OneWay Binding Mode example&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;OneWay Binding&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; Note:&lt;b&gt; If Source Changes then only UI will Updated. Use this only when you want to display read only data in the UI.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
OneTime:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;b&gt;Binding Mode&lt;/b&gt; is &lt;b&gt;OneTime&lt;/b&gt;, then&lt;b&gt; it sends data from source to target, but it does this only&amp;nbsp; when application started or DataContext changes.&lt;/b&gt; So in our example change the&lt;b&gt; Mode &lt;/b&gt;Attribute value to &lt;b&gt;OneTime &lt;/b&gt;and set the ListBox&#39;s SelectedIndex to 0 then run the example you will notice that only default value is shown in targets, eventhough we select another color then target&#39;s value can not change.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-2RQI2hxj7PM/Ugr4FNRz7GI/AAAAAAAAA1g/588bl-L14hc/s1600/One+Time+Binding+Mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;OneTime Binding mode&quot; border=&quot;0&quot; height=&quot;138&quot; src=&quot;http://4.bp.blogspot.com/-2RQI2hxj7PM/Ugr4FNRz7GI/AAAAAAAAA1g/588bl-L14hc/s640/One+Time+Binding+Mode.png&quot; style=&quot;cursor: move;&quot; title=&quot;OneTime Binding mode in wpf&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;OneTime Binding Mode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; We can use this &lt;b&gt;to show read only data in control as it was loaded.&lt;/b&gt; We can use this to compare the changes occurred in the UI with Default values. &lt;b&gt;This is best when source Doesn&#39;t Implement INofityPropertyChanged Interface.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
OneWayToSource:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This mode is reverse to &lt;b&gt;OneWay &lt;/b&gt;Mode, When &lt;b&gt;Mode&lt;/b&gt; is set to&lt;b&gt; OneWayToSource&lt;/b&gt; then &lt;b&gt;if target value is changed by user then that value is updated to source.&amp;nbsp;&lt;/b&gt; In our example change the&lt;b&gt; Mode&lt;/b&gt; to &lt;b&gt;OneWayToSource&lt;/b&gt; and run the example you will notice that target&#39;s can not have any values, Now write any color in TextBox, when focus leaves then source will be updated for default selectedindex not the current selected index. But here &lt;b&gt;Changed Data in Source can not be updated in target.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-TSvr7kYXmPE/Ugr8KIteK2I/AAAAAAAAA1w/cc2AxMWs150/s1600/OneWayToSource+Binding+Mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;OneWayToSource Binding Mode example&quot; border=&quot;0&quot; height=&quot;130&quot; src=&quot;http://2.bp.blogspot.com/-TSvr7kYXmPE/Ugr8KIteK2I/AAAAAAAAA1w/cc2AxMWs150/s640/OneWayToSource+Binding+Mode.png&quot; title=&quot;OneWayToSource Binding Mode in WPF&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;OneWayToSource Binding Mode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; We have to use this &lt;b&gt;Binding Mode when user can able to change the source data and changed data can not be updated in Target UI.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
TwoWay:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; If you set &lt;b&gt;Mode&lt;/b&gt; to &lt;b&gt;TwoWay&lt;/b&gt; then &lt;b&gt;Whenever Source Property Changed then Target will be udpated, similarly if target values changes, changes will be updated in source property.&lt;/b&gt; Set the Mode two way in our example run it, You will notice that whenever&amp;nbsp; ListBox selection changes it will be updated in TextBlock and TextBoxes. If we change the value in TextBox then Source is Updated and also target updated with these values.&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-IcRqCPgp2hs/UgsJTbhRlOI/AAAAAAAAA20/6K8L83FnuW8/s1600/Two+Way+Binding+Mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;TwoWay DataBinding Mode example&quot; border=&quot;0&quot; height=&quot;138&quot; src=&quot;http://2.bp.blogspot.com/-IcRqCPgp2hs/UgsJTbhRlOI/AAAAAAAAA20/6K8L83FnuW8/s640/Two+Way+Binding+Mode.png&quot; title=&quot;TwoWay Data Binding Mode&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;TwoWay Data Binding&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&amp;nbsp;&amp;nbsp; Use this binding &lt;b&gt;when user can able to change data source and that changes will be updated to targets.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Default: &lt;/b&gt;In addition to these&lt;b&gt; &lt;/b&gt;four Binding Modes &lt;b&gt;Default&lt;/b&gt; Binding Mode exist.&lt;b&gt; If you don&#39;t specify any binding Mode in Binding element then Default will take place.&lt;/b&gt; &lt;b&gt;Defualt binding mode&lt;/b&gt; choose binding mode depending upon the &lt;b&gt;target controls Dependency Property.&lt;/b&gt; For Example TextBox control Text property has binding mode as TwoWay in the same it will take for other controls.&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;UpdateSourceTrigger:&lt;/a&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It is the property of Binding element, indicates or defines when should be the target value updated in the source.&lt;/h4&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I hope you are clear about&lt;b&gt; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-modes-in-wpf.html&quot; target=&quot;_blank&quot;&gt;binding modes in wpf.&lt;/a&gt;&lt;/b&gt; So what do you thinking about binding modes now.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and Share for our friends if you like this post. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Related Posts:&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/DataContext-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;DataContext Property Usage in WPF.&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/binding-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Data Binding Basics.&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/updatesourcetrigger-property-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to use UpdateSourceTrigger Property while Binding in TwoWay Mode.&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/INotifyPropertyChanged-in-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;INotifyPropertyChanged Interface Usage.&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/xml-data-binding-wpf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to Bind XML Data to ListView Using XmlDataProvider. &amp;nbsp;&lt;/b&gt; &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4982678700685000248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/binding-modes-in-wpf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4982678700685000248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4982678700685000248'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/binding-modes-in-wpf.html' title=' Binding Modes in WPF with Example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-cMza8K9B9iA/Ugr1WoDDcqI/AAAAAAAAA1Q/UUZRqSzlN64/s72-c/One+Way+Binding.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-3364129010032269563</id><published>2013-08-08T11:45:00.000+05:30</published><updated>2015-01-17T01:03:16.194+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="OopsConcepts"/><title type='text'>Introduction to Object Oriented Programming(oops) Concepts in C#.Net With Examples</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Object Oriented Programming Concepts in C#.Net:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This page contains list of&amp;nbsp; Object Oriented Programming Concepts i have written in this blog. You can find other Pages About .Net Technologies like WPF,Asp.Net, C#.Net,Vb.Net and Ado.Net.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp; All the tutorials are given with examples. Go through it you will find enough information. This page is sitemap for oops concepts in this site.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/06/Access-Specifiers-Modifiers-in-CSharp-with-examples.html&quot; target=&quot;_blank&quot;&gt;Access Specifiers in C#.Net&lt;/a&gt;&lt;/b&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Article explains what are the access specifiers available in C#.Net and How to use them with example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/06/access-specifiers-in-csharp-in-diagramatic-format-example.html&quot; target=&quot;_blank&quot;&gt;Access Specifiers in C#.Net in Diagrammatic Format&lt;/a&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Article gives you clear picture Access Modifiers for easily remembering hierarchy of usage of Access Specifiers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/Abstract-Classes-and-Abstract-methods-In-CSharp.Net-OopsProgramming-Example.html&quot; target=&quot;_blank&quot;&gt;Abstract Classes and Abstract Methods in C#.Net&lt;/a&gt;&lt;/b&gt; 
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Oops Concept focuses on Abstract Types in C#.Net. Learn about how to create abstract class and Abstract methods and usage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/Static-Classes-and-Static-members-in-C.Net-Example-Oops-programming-what-is.html&quot; target=&quot;_blank&quot;&gt;Static Classes and Static Class Members&amp;nbsp;&lt;/a&gt;&lt;/b&gt; 
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Article focuses on creation of Static Classes in Oops Programming and How to Consume them in C#.Net &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/Sealed-Class-in-Cnet-with-Example-Oops-Programming-what-is-Use.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Sealed Classes and what is the use of them&lt;/b&gt;&lt;/a&gt; 
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Article gives when to use Sealed Classes and what is their purpose.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/parital-class-in-csharp-example-what-is-the-use-difference-to-class.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Partial Class in C#.Net&amp;nbsp;&lt;/b&gt;&lt;/a&gt; 
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Article gives brief explanation about How partial classes helps developers to work on one class at a time by multiple developers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/Interfaces-in-csharp-why-use-of-Interfaces-what-are-uses-how-different-from-classes.html&quot; target=&quot;_blank&quot;&gt;Interfaces in C#.Net&lt;/a&gt;&lt;/b&gt; 

&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Article focuses on purpose of interfaces and when to use interfaces.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/How-to-find-all-type-Children-Controls-in-Container-Controls-loop-iterate-through-all-controls-wpf-window-forms-code-behind.html&quot; target=&quot;_blank&quot;&gt;How to identify the particular type of children control in a container control&lt;/a&gt;&lt;/b&gt; 

&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Some times while programming we need to identify the particular type of controls and assign them certain settings in code behind file so in that case this article gives you how to catch the elements of container control in code behind file dynamically.&lt;br /&gt;
&lt;br /&gt;
I will update this whenever i post any new articles about Oops Programming.&lt;br /&gt;
Keep Visiting Thank you.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/3364129010032269563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/oops-concets-in-Csharp.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3364129010032269563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3364129010032269563'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/oops-concets-in-Csharp.html' title='Introduction to Object Oriented Programming(oops) Concepts in C#.Net With Examples'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-5511915018646534831</id><published>2013-08-08T09:12:00.001+05:30</published><updated>2015-01-17T01:03:52.165+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="RichTextBox"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF Controls"/><title type='text'>How to add, read, clear the text content in richtextbox control in wpf</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
How to get, set, clear the text in richtextbox control in wpf&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article you will know&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;how to assign the text to richtextbox in wpf,&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&amp;nbsp;how to read and clear the text from richtextbox,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;how to enable the spell check for richtextbox in wpf,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;what is the replacement text property for richtextbox,&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&amp;nbsp;how to set the margins for richtextbox paragraphs.&amp;nbsp;&lt;/b&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;https://app.box.com/s/pm9dr811ro1d0cekjp0b&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Download Source Code &lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=kZH6H0Ek6Gs&quot; target=&quot;_blank&quot;&gt;and Video explaining How to add, read, clear the text in RichTextBox&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;

&lt;/span&gt;&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Description:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In the previous articles i explained basic &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt; concepts like &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt;What is wpf and it&#39;s features&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/WPF-vs-Windows-Forms-difference-between-wpf-windows-forms-in-events-properites-methods-for-control.html&quot; target=&quot;_blank&quot;&gt;Wiindows Forms vs WPF Future,&lt;/a&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/what-is-xaml-File-compilation-process-attribute-property-element-Syntaxes.html&quot; target=&quot;_blank&quot;&gt; what is XAML and it&#39;s compilation process&lt;/a&gt;,&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;WPF Architecture&lt;/a&gt; etc.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;What is the replacement Text property for RichTextBox in&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt; WPF&lt;/a&gt;:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unlike other controls in wpf, &lt;b&gt;richtextbox&lt;/b&gt; doesn&#39;t have content as property for setting content. &lt;b&gt;Richtextbox&lt;/b&gt; has &lt;b&gt;Document&lt;/b&gt; property to set or get the content or text. Here this Document is &lt;b&gt;FlowDocumen&lt;/b&gt;t type. Here this &lt;b&gt;FlowDocumen&lt;/b&gt;t may contain multiple paragraphs.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;How to add text to richtextbox control:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; As the &lt;b&gt;Document Property&lt;/b&gt; of the &lt;b&gt;RichTextBox&lt;/b&gt; is the &lt;b&gt;FlowDocument&lt;/b&gt; type so we have create an object of type &lt;b&gt;FlowDocument,&lt;/b&gt; and add paragraphs to Blocks property of&lt;b&gt; FlowDocument&lt;/b&gt; and Finally assign this &lt;b&gt;FlowDocument &lt;/b&gt;to Document Property of &lt;b&gt;RichTextBox&lt;/b&gt; Control.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here is the Code showing how to add text to richtextbox control in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt; using &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/C#.Net&quot; target=&quot;_blank&quot;&gt;C#.Net&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;            // Create a Flow Document
            FlowDocument ObjFdoc = new FlowDocument();

            //Add paragraphs to flowdocument Blocks property

            Paragraph ObjPara1 = new Paragraph();
       
            ObjPara1.Inlines.Add(new Run(&quot; First Paragraph &quot;));

            Paragraph ObjPara2 = new Paragraph();
            ObjPara2.Inlines.Add(new Run(&quot;Second Paragraph&quot;));

            ObjFdoc.Blocks.Add(ObjPara1);
            ObjFdoc.Blocks.Add(ObjPara2);

            // Finally Assign the FlowDocuemnt object to Document Property fo RichTextBox Control.

            richTextBox1.Document=ObjFdoc;




&lt;/textarea&gt;




&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;Vb.Net Code for addding text to richtextbox&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;vb&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;&#39; Create a Flow Document
Dim ObjFdoc As New FlowDocument()

&#39;Add paragraphs to flowdocument Blocks property

Dim ObjPara1 As New Paragraph()

ObjPara1.Inlines.Add(New Run(&quot; First Paragraph &quot;))

Dim ObjPara2 As New Paragraph()
ObjPara2.Inlines.Add(New Run(&quot;Second Paragraph&quot;))

ObjFdoc.Blocks.Add(ObjPara1)
ObjFdoc.Blocks.Add(ObjPara2)

&#39; Finally Assign the FlowDocuemnt object to Document Property fo RichTextBox Control.

richTextBox1.Document = ObjFdoc


&lt;/textarea&gt;

&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;
&lt;span style=&quot;color: blue;&quot;&gt;How to read Text from RichTextBox Control:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; To read text from RichTextBox FlowDocument type we have to use TextRange( ).&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Code to Read text RichTextBox using &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/C#.Net&quot; target=&quot;_blank&quot;&gt;C#.Net&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;vb&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;6&quot;&gt;string richText = new TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd).Text;

&lt;/textarea&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Vb.Net Code&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;vb&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;6&quot;&gt;Dim richText As String = New TextRange(richTextBox1.Document.ContentStart, richTextBox1.Document.ContentEnd).Text

&lt;/textarea&gt;


&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;How to Clear Text in RichTextBox:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; While Adding text to &lt;b&gt;richtextbox&lt;/b&gt;, we added paragraphs to Blocks property of&lt;b&gt; FlowDocument&lt;/b&gt; type, so for clearing text we have to clear the &lt;b&gt;Blocks&lt;/b&gt; of Document in the following two ways.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/C#.Net&quot; target=&quot;_blank&quot;&gt;C#.Net&amp;nbsp;&lt;/a&gt; Code:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;vb&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;6&quot;&gt;            richTextBox1.Document.Blocks.Clear();

            // OR

            richTextBox1.SelectAll();
            richTextBox1.Selection.Text = &quot;&quot;;

&lt;/textarea&gt;


&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Vb.Net Code:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;vb&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;6&quot;&gt;         

richTextBox1.Document.Blocks.Clear()

&#39; OR

richTextBox1.SelectAll()
richTextBox1.Selection.Text = &quot;&quot;

&lt;/textarea&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Setting Margin for RichTextBox paragraphs:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; While adding text using&lt;b&gt; paragraphs&lt;/b&gt; we may get more space between para&#39;s in &lt;b&gt;richtextbox&lt;/b&gt; so to set the margin between paragraphs use below code in resources section of XAML code.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt;            &lt;richtextbox&gt;
                &lt;RichTextBox.Resources&gt;
                    &lt;style TargetType=&quot;{x:Type Paragraph}&quot;&gt;
                    &lt;setter  Value=&quot;0&quot; Property=&quot;Margin&quot;/&gt;
                    &lt;/Style&gt;
                &lt;/RichTextBox.Resources&gt;
            &lt;/RichTextBox&gt;


&lt;/textarea&gt; 


&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Enabling Spell Check:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
RichTextBox has spell check feature this can be enabled by setting&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;richTextBox1.SpellCheck.IsEnabled = true;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;You can find the video explained with &lt;a href=&quot;http://youtu.be/kZH6H0Ek6Gs&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;example on how to add, read,&amp;nbsp; clear the content in wpf richtextbox control&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/kZH6H0Ek6Gs&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;

&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-20a62TvY7YE/UgMTSXVPxgI/AAAAAAAAAV0/jH1MhOa153s/s1600/add-read-clear+text+in+richtextbox.png&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you are clear about&lt;b&gt; reading, adding ,clearing the text from richtextbox control.&lt;/b&gt; I hope you will see the &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF Tutorials section&lt;/a&gt; for More Tutorials and How to&#39;s .&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and Share if you like this post for our friends. Thank You.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;/h4&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/5511915018646534831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/how-add-read-clear-text-content-in-richtextbox-set-margin-in-wpf-using-Csharp-Vb.Net.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/5511915018646534831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/5511915018646534831'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/how-add-read-clear-text-content-in-richtextbox-set-margin-in-wpf-using-Csharp-Vb.Net.html' title='How to add, read, clear the text content in richtextbox control in wpf'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4892971040342591517</id><published>2013-08-07T09:00:00.000+05:30</published><updated>2015-01-17T01:04:16.078+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ado.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="C#.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="VB.Net"/><title type='text'>How to perform select, insert,update,delete operations using SqlCommand Object C#.Net and Vb.Net </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Select,Insert,Update,Delete Operations on Database:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Introduction:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article you will learn &lt;b&gt;how to use SqlCommand Object in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Ado.Net&quot; target=&quot;_blank&quot;&gt;Ado.Net&lt;/a&gt; for doing Select, Insert, Update, Delete operations against database. &lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You will also learn &lt;b&gt;different overloading methods for instantiation of SqlCommand Object, How to set CommandText as insert, update,delete sql statements,&amp;nbsp; what are the different methods available for execution of queries against database, How to use ExecuteScalar( ), ExecuteReader( ), ExecuteNonQuery( ) methods.&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Description:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In the previous articles i explained&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt; Introduction to Ado.Net Part1,&lt;/b&gt;&lt;/a&gt; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/Introdution-to-ado.net-part2-sendings-SqlCommand-Object-Getting-Result-back-using-DataReader.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Part2&lt;/b&gt;&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/how-to-set-connection-string-for-sqlconnection-to-connect-to-sql-database-example-csharp.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;How to establish connection to database.&lt;/b&gt;&lt;/a&gt; In Ado.Net next step is to learn about SqlCommand Object.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SqlCommand:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; While doing database operations using &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Ado.Net&quot; target=&quot;_blank&quot;&gt;Ado.Net&lt;/a&gt; , after &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/how-to-set-connection-string-for-sqlconnection-to-connect-to-sql-database-example-csharp.html&quot; target=&quot;_blank&quot;&gt;establishing connection to database&lt;/a&gt; next step is to Set the &lt;b&gt;CommandText&lt;/b&gt; in &lt;b&gt;SqlCommand&lt;/b&gt; Object.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;SqlCommand&lt;/b&gt; Object is exist in &lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;System.Data.SqlClient&lt;/b&gt;&lt;/span&gt; namespace which is defined in &lt;span style=&quot;color: blue;&quot;&gt;System.Data.dll&lt;/span&gt; assembly.&amp;nbsp; &lt;b&gt;SqlCommand&lt;/b&gt; object has four overloads exist i.e&lt;/div&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt;                SqlCommand obj = new SqlCommand();
                SqlCommand obj = new SqlCommand(string CmdText);
                SqlCommand obj=new SqlCommand(string CmdText,SqlConnection Con);
                SqlCommand obj=new SqlCommand(stringCmdText,SqlConnection Con,SqlTransaction Tran);


&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
As you saw we can instantiate the &lt;b&gt;SqlCommand &lt;/b&gt;Object in four ways.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SqlCommand Methods:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;b&gt;SqlCommand&lt;/b&gt; Class provides three methods to execute queries against database.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
These are&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;ExecuteReader( )&lt;/b&gt; for Select Operation&lt;/li&gt;
&lt;li&gt;&lt;b&gt;ExecuteNonQuery( )&lt;/b&gt; for Insert, Update, Delete operations&lt;/li&gt;
&lt;li&gt;&lt;b&gt;ExecuteScalar( )&lt;/b&gt; for Getting Single Value.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ExecuteReader( ):&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;If you want to perform select operation on database that returns data as rows and columns then you have to call &lt;b&gt;ExecuteReader( )&lt;/b&gt; method after setting &lt;b&gt;CommandText&lt;/b&gt; as&lt;b&gt; Sql Select Statement&lt;/b&gt;. This method returns object of the&lt;b&gt; class DataReader&lt;/b&gt; which holds data as &lt;b&gt;rows and columns.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Below code contains&lt;b&gt; how to set the CommandText as Sql Select Statement in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/C%23.Net&quot; target=&quot;_blank&quot;&gt;C#.Net&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/VB.Net&quot; target=&quot;_blank&quot;&gt;Vb.Net&lt;/a&gt;.&amp;nbsp;&lt;/b&gt; I am using &lt;b&gt;Dept table&lt;/b&gt; which have Id,Dname,Loc columns.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;35&quot;&gt;C#.Net Code


            SqlDataReader ObjRdr = null;
            try
            {

                SqlConnection ObjCon = new SqlConnection(&quot;Database=cs9db; data source=(local); integrated security=sspi;&quot;);
                
                // Opening the connection
                ObjCon.Open();
                
                // Instantiation of SqlCommand Object with a query and Connection reference
                SqlCommand ObjCmd = new SqlCommand(&quot;Select DName from Dept&quot;, ObjCon);
                // Calling ExecuteReader() method
                ObjRdr = ObjCmd.ExecuteReader();

                // Print the Deptname for each record
                while (ObjRdr.Read())
                {
                    Console.WriteLine(ObjRdr[0]);
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            { // if reader is open then closing the reader
                if (ObjRdr != null)
                {
                    ObjRdr.Close();
                }
                // If Connection is open then closing the conneciton
                if (ObjCon.State != ConnectionState.Closed)
                {
                    ObjCon.Close();
                }
            }

Vb.Net Code


Dim ObjRdr As SqlDataReader = Nothing
Try

 Dim ObjCon As New SqlConnection(&quot;Database=cs9db; data source=(local); integrated security=sspi;&quot;)

 &#39; Opening the connection
 ObjCon.Open()

 &#39; Instantiation of SqlCommand Object with a query and Connection reference
 Dim ObjCmd As New SqlCommand(&quot;Select DName from Dept&quot;, ObjCon)
 &#39; Calling ExecuteReader() method
 ObjRdr = ObjCmd.ExecuteReader()

 &#39; Print the Deptname for each record
 While ObjRdr.Read()
  Console.WriteLine(ObjRdr(0))

 End While
Catch ex As Exception
 Console.WriteLine(ex.Message)
Finally
 &#39; if reader is open then closing the reader
 If ObjRdr IsNot Nothing Then
  ObjRdr.Close()
 End If
 &#39; If Connection is open then closing the conneciton
 If ObjCon.State &lt;&gt; ConnectionState.Closed Then
  ObjCon.Close()
 End If
End Try



&lt;/textarea&gt;



&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ExecuteNonQuery( ):&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If you want to perform any &lt;b&gt;DML operation like insert, update, delete&lt;/b&gt; then you have to use &lt;b&gt;ExecuteNonQuery( )&lt;/b&gt; methods. It &lt;b&gt;returns an integer&lt;/b&gt; specifying that number of rows affected. If any error occur it &lt;b&gt;returns -1.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Below code contains &lt;b&gt;how to set the CommandText as DML statement and How to call ExecuteNonQuery() method in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/C%23.Net&quot; target=&quot;_blank&quot;&gt;C#.Net&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/VB.Net&quot; target=&quot;_blank&quot;&gt;VB.Net.&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;30&quot;&gt;C#.Net Code

try
            {
                SqlConnection ObjCon = new SqlConnection(&quot;Database=cs9db; data source=(local); integrated security=sspi;&quot;);
                
                // Opening the Connection
                ObjCon.Open();

                // Insertion

                // Prepare Command String
                string InsertStmt=@&quot;Insert into Dept(DName,Loc) values(&#39;Sales Dept&#39;,30)&quot;;
                
                // Instantiation of SqlCommand Object with CommandText
                SqlCommand ObjCmd = new SqlCommand(InsertStmt);
                
                // Updation
                // Instantiation of SqlCommmand Object 
                string UpdateStmt = @&quot;Update Dept set DName=&#39;IT Dept&#39; where Deptno=30&quot;;
                
                SqlCommand ObjCmd = new SqlCommand();
                ObjCmd.CommandText = UpdateStmt;

                // Deletion

                string DeleteStmt = @&quot; Delete from Dept where Deptno=30&quot;;
                SqlCommand objCmd = new SqlCommand();
                objCmd.CommandText = DeleteStmt;


                
                // Adding Connection object to Command Object
                ObjCmd.Connection = ObjCon;
                
                // Calling ExecuteNonQuery() method
              int Count=ObjCmd.ExecuteNonQuery();
              if (Count &gt; 0)
              {
                  Console.WriteLine(&quot;DML statement Executed Successfully&quot;);
              }
              else
              {
                  Console.WriteLine(&quot;Error Occured in Executing DML Statement&quot;);
              }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            { 
                // If Connection is open then closing the conneciton
                if (ObjCon.State != ConnectionState.Closed)
                {
                    ObjCon.Close();
                }
            }

VB.Net Code

Try
 Dim ObjCon As New SqlConnection(&quot;Database=cs9db; data source=(local); integrated security=sspi;&quot;)

 &#39; Opening the Connection
 ObjCon.Open()

 &#39; Insertion

 &#39; Prepare Command String
 Dim InsertStmt As String = &quot;Insert into Dept(DName,Loc) values(&#39;Sales Dept&#39;,30)&quot;

 &#39; Instantiation of SqlCommand Object with CommandText
 Dim ObjCmd As New SqlCommand(InsertStmt)

 &#39; Updation
 &#39; Instantiation of SqlCommmand Object 
 Dim UpdateStmt As String = &quot;Update Dept set DName=&#39;IT Dept&#39; where Deptno=30&quot;

 Dim ObjCmd As New SqlCommand()
 ObjCmd.CommandText = UpdateStmt

 &#39; Deletion

 Dim DeleteStmt As String = &quot; Delete from Dept where Deptno=30&quot;
 Dim objCmd As New SqlCommand()
 objCmd.CommandText = DeleteStmt



 &#39; Adding Connection object to Command Object
 ObjCmd.Connection = ObjCon

 &#39; Calling ExecuteNonQuery() method
 Dim Count As Integer = ObjCmd.ExecuteNonQuery()
 If Count &gt; 0 Then
  Console.WriteLine(&quot;DML statement Executed Successfully&quot;)
 Else
  Console.WriteLine(&quot;Error Occured in Executing DML Statement&quot;)

 End If
Catch ex As Exception
 Console.WriteLine(ex.Message)
Finally
 &#39; If Connection is open then closing the conneciton
 If ObjCon.State &lt;&gt; ConnectionState.Closed Then
  ObjCon.Close()
 End If
End Try




&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;ExecuteScalar( ):&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want to execute any query that returns &lt;b&gt;single value&lt;/b&gt; then you have to call&lt;b&gt; ExecuteScalar( ) &lt;/b&gt;method of &lt;b&gt;Command Object.&lt;/b&gt; It returns the single value in the form of object type, you have to cast it to use the value.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Below code contains &lt;b&gt;how to call ExecuteScalar( ) method for Getting Single value result in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/C%23.Net&quot; target=&quot;_blank&quot;&gt;C#.Net &lt;/a&gt;and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/VB.Net&quot; target=&quot;_blank&quot;&gt;VB.Net.&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;35&quot;&gt;C#.Net Code

 try
            {
                string SelectStmt = &quot;Select Count(*) from dept&quot;;
                SqlConnection ObjCon = new SqlConnection(&quot;Database=cs9db; data source=(local); integrated security=sspi;&quot;);
                // Opening the Connection
                ObjCon.Open();

                //Instantiation SqlCommand Object

                SqlCommand objCmd = new SqlCommand();
                objCmd.Connection = ObjCon;
                objCmd.CommandText = SelectStmt;

                //Calling ExecuteNonQuery() method
                Count=(int)objCmd.ExecuteScalar();


            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                // If Connection is open then closing the conneciton
                if (ObjCon.State != ConnectionState.Closed)
                {
                    ObjCon.Close();
                }
            }

VB.Net Code

Try
 Dim SelectStmt As String = &quot;Select Count(*) from dept&quot;
 Dim ObjCon As New SqlConnection(&quot;Database=cs9db; data source=(local); integrated security=sspi;&quot;)
 &#39; Opening the Connection
 ObjCon.Open()

 &#39;Instantiation SqlCommand Object

 Dim objCmd As New SqlCommand()
 objCmd.Connection = ObjCon
 objCmd.CommandText = SelectStmt

 &#39;Calling ExecuteNonQuery() method


 Count = CInt(objCmd.ExecuteScalar())
Catch ex As Exception
 Console.WriteLine(ex.Message)
Finally
 &#39; If Connection is open then closing the conneciton
 If ObjCon.State &lt;&gt; ConnectionState.Closed Then
  ObjCon.Close()
 End If
End Try
&lt;/textarea&gt;




&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Conclusion:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you know the &lt;b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/how-to-use-sqlcommand-for-select-insert-update-delete-CSharp.Net-Vb.Net-Example.html&quot; target=&quot;_blank&quot;&gt;importance of SqlCommand Object in Ado.Net,&lt;/a&gt; How to set the CommandText , how to call ExecuteScalar( ), ExecuteReader( ), ExecuteNonQuery( ).&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; In next articles will see &lt;b&gt;how to pass parameters to SqlCommand Object, How to use stored Procedures in SqlCommand .&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Don&#39;t forget to Comment and Share if you like this post for our friends. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;

&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4892971040342591517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/how-to-use-sqlcommand-for-select-insert-update-delete-CSharp.Net-Vb.Net-Example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4892971040342591517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4892971040342591517'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/how-to-use-sqlcommand-for-select-insert-update-delete-CSharp.Net-Vb.Net-Example.html' title='How to perform select, insert,update,delete operations using SqlCommand Object C#.Net and Vb.Net '/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-1482552480424925359</id><published>2013-08-06T14:12:00.000+05:30</published><updated>2015-01-17T01:04:31.032+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ado.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Connection String"/><title type='text'> How to set connectionstring for SqlConnection Object to connect to sql server database with example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Setting Connection String for Sql Server Database&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Introduction:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article you will learn about&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;how to set connection string parameter in SqlConnection Object,&lt;/b&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;how to instantiate the SqlConnection,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How to open the connection,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How to pass the connection object to other ADO.NET objects,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How it perform operations with other Ado.Net Objects,&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How to close the connection. &lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can also find&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html&quot; target=&quot;_blank&quot;&gt; Introduction to Ado.Net Part1&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/Introdution-to-ado.net-part2-sendings-SqlCommand-Object-Getting-Result-back-using-DataReader.html&quot; target=&quot;_blank&quot;&gt;Part2&lt;/a&gt; to know briefly about&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/Introdution-to-ado.net-part2-sendings-SqlCommand-Object-Getting-Result-back-using-DataReader.html&quot; target=&quot;_blank&quot;&gt; Ado.Net Data Providers.&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Description:&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; While doing any crud operations with sql database first we have to create connection to sql server database.&amp;nbsp; To Connect with sql server database from .net applications Ado.Net Provides two providers &lt;b&gt;OledbConnetion&lt;/b&gt; and &lt;b&gt;SqlConnection Object.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;SqlConnection Object:&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To interact with database, you must have connection to it. The Connection Object helps to identify the datasource, database, User Id and Password etc connection string parameters required to connect to a database.&amp;nbsp; So this &lt;b&gt;SqlConnection &lt;/b&gt;object is used by &lt;b&gt;SqlCommand&lt;/b&gt; object so that they will know which database to execute query.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;SqlConnection&lt;/b&gt; object exist in &lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;System.Data.SqlClient&lt;/b&gt;&lt;/span&gt; namespace which is defined in &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;System.Data&lt;/span&gt;&lt;/b&gt; assembly.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;SqlConnection&lt;/b&gt; object has following constructors&lt;br /&gt;
&lt;br /&gt;
i.e SqlConnection()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlConnection(string ConnectionString)&lt;br /&gt;
&lt;br /&gt;
Here &lt;b&gt;Connection String&lt;/b&gt; is a collection of attributes where it contains following attributes&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;- Data Source&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;- User Id and Password&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;- Trusted_Connection or Integrated Security &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;- Database or Initial Catalog&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;- Provider&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I explained these briefly in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/connection-string-parameters-for-sql-database-oralce-database-with-example.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Connection String Parameters for sql and Oracle databases.&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Sql Server &lt;/b&gt;Database provides two modes for connecting to it from &lt;b&gt;.Net applications.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Sql Server Authentication.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&quot;Provider=SqlOledb;User Id=Sa;Password=&lt;/b&gt;&lt;pwd&gt;&lt;b&gt;;&lt;br /&gt;Database=&lt;/b&gt;&lt;db name=&quot;&quot;&gt;&lt;b&gt;[;Data Source=&lt;/b&gt;&lt;server&gt;&lt;b&gt;]&quot;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Windows Authentication.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;In windows authentication no need to provide User Id and Password parameters&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&quot;Provider=SqlOledb; Trusted_Connection= true/ Integrated Security= SSPI;&lt;br /&gt;Database=&lt;db name=&quot;&quot;&gt;[;Data Source=&lt;server&gt;]&quot;&lt;/server&gt;&lt;/db&gt;&lt;/b&gt;&lt;/server&gt;&lt;/db&gt;&lt;/pwd&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;SqlConnection&lt;/b&gt; Object goes through these sequence of operations while communicating with data sources.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; 1). Instantiate of SqlConnection.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2). Open the Connection.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3). Pass the connection to other Ado.Net objects.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4). Doing database operations along with other Ado.Net Objects.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 5). Closing the Connection&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In the below code i explained these five steps in clear manner&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;65&quot;&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// Importing namespaces required 
using System.Data;
using System.Data.SqlClient;

namespace LINQ_Practice
{
    class SqlConnentionDemo
    {
        static void Main(string[] args)
        {
            // 1. Instantiation of SqlConnection Object
            // Windows Authentication
            //SqlConnection ObjCon = new SqlConnection(&quot;data source=(local); trusted_Connection=true; initial catalog=cs9db&quot;);
            // Sql Server Authentication
            SqlConnection ObjCon = new SqlConnection(&quot;data source=(local); userid=sa;password=9290812112; initial catalog=cs9db&quot;);
            SqlDataReader ObjRdr = null;
            try
            {
                // 2. Opening the connection
                ObjCon.Open();
                //3. Passing connection to other Ado.Net Objects.
                SqlCommand ObjCmd = new SqlCommand(&quot;Select * from Dept&quot;, ObjCon);
                
                // 4. Performing database operations with other Ado.Net Objects.
                ObjRdr = ObjCmd.ExecuteReader();

                // Priniting the Result
                while (ObjRdr.Read())
                {
                    Console.WriteLine(ObjRdr[2]);
                }
                Console.ReadLine();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                // if reader is open then closing the reader
                if (ObjRdr != null)
                {
                    ObjRdr.Close();
                }
                //5. If Connection is open then closing the conneciton
                if (ObjCon.State != ConnectionState.Closed)
                {
                    ObjCon.Close();
                }
            }
        }
    }
}




&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
As you saw in code at 1. we are creating an instance of&lt;b&gt; SqlConnection&lt;/b&gt; class by specifying &lt;b&gt;Connection String&lt;/b&gt; in both &lt;b&gt;Sql Server&lt;/b&gt; and&lt;b&gt; windows authentication modes&lt;/b&gt;. We can use one mode. at step 2. we opened the connection with database by calling&lt;b&gt; Open( ) &lt;/b&gt;method of &lt;b&gt;SqlConnection Object.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; At step 3 we added &lt;b&gt;SqlConnection&lt;/b&gt; Object to&lt;b&gt; SqlCommand&lt;/b&gt; as parameter. At step 4 Connection object perform database operations along with &lt;b&gt;SqlCommand&lt;/b&gt; and &lt;b&gt;SqlDataReader&lt;/b&gt; object. We will see &lt;b&gt;SqlCommand&lt;/b&gt; and &lt;b&gt;SqlDataReader&lt;/b&gt; in later. At Step 5 we closed the connection. It is always good practice to know the status of the connection before closing the connection. &lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Conclusion:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you understand the &lt;b&gt;purpose and need of SqlConnection Object, How to pass Connection String parameters as key/value pairs while instantiation, How it is used in database operations,&lt;/b&gt; Finally&lt;b&gt; how to close the Connection.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Don&#39;t forget to Comment and Share if you like this post for our friends. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/1482552480424925359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/how-to-set-connection-string-for-sqlconnection-to-connect-to-sql-database-example-csharp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1482552480424925359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1482552480424925359'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/how-to-set-connection-string-for-sqlconnection-to-connect-to-sql-database-example-csharp.html' title=' How to set connectionstring for SqlConnection Object to connect to sql server database with example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-2099481962847241959</id><published>2013-08-06T12:16:00.000+05:30</published><updated>2014-12-20T22:14:46.992+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ado.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Connection String"/><title type='text'>Connection string parameters for Sql database and Oracle database with Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Connection string parameters for SqlConnection ,Oralce Connection objects to Connect with Sql Server and Oracle databases&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this article you will learn &lt;b&gt;what are the different connection string parameters need to set while connecting with either Sql Database or Oracle database.&lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my previous article &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html&quot; target=&quot;_blank&quot;&gt;Introduction to Ado.Net part1&lt;/a&gt; i mention that &lt;b&gt;Creating connection is the first step while connecting with data sources.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; So to establish connection with &lt;b&gt;Sql Server database&lt;/b&gt; we use &lt;b&gt;SqlConnection object&lt;/b&gt; in the same manner &lt;b&gt;OracleConnection object&lt;/b&gt; to connect with &lt;b&gt;Oracle database.&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Constructors are as follows&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;SqlConnection(string ConnectionString)&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;OralceConnection(string ConnectionString).&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here &lt;b&gt;ConnectionString&lt;/b&gt; is a collection of attributes that are required while connecting with datasources. &lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Connection String Parameters:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here this connection string attributes has some parameters exist. Some of these parameters are common to both &lt;b&gt;SqlConnection&lt;/b&gt; and&lt;b&gt; OracleConnetion&lt;/b&gt; objects. These are&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Provider&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Data Source&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - User Id and Password&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Database or Initial catalog&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - Trusted_Connection or Integrated Security&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; - DSN&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
we will see each these in detail now.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Provider:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As i mentioned in Ado.Net introduction , provider is required while connecting with datasource. Ado.Net provides different types of providers for connecting different types of data sources.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here is the list Providers that Ado.Net Provides.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Oralce &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Msdaora&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;SqlServer &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sqloledb&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Ms-Access or Ms-Excel&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Microsoft.Jet.Oledb.4.0 &lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Ms-Indexing Server&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Msidxs&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Data Source:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; It is the name of the machine on which the our required database exist, it is optional when our database exist on local machine, it is required when database is on remote machine.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;User Id and Password:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; As we know databases store secured information we need to provide &lt;b&gt;User Id and Password&lt;/b&gt; for connecting with databases in secured mode.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;b&gt;&amp;nbsp; Oracle &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scott/tiger&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sql Server &amp;nbsp; &amp;nbsp;&amp;nbsp; sa/&lt;pwd&gt;&lt;/pwd&gt;&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Database or Initial Catalog:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; These attributes are required only while connecting with &lt;b&gt;Sql Server Database&lt;/b&gt; as it contains multiple databases. It is the &lt;b&gt;database name&lt;/b&gt; to which we need to connect.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Trusted_Connection or Integrated Security:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; These attributes also required only while connecting with &lt;b&gt;Sql Server Database&lt;/b&gt;&amp;nbsp; in &lt;b&gt;Windows authentication mode&lt;/b&gt; only. In this case we don&#39;t need to provide &lt;b&gt;User Id and Password&lt;/b&gt; attributes in the &lt;b&gt;Connection String.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
we provide &lt;b&gt;Trusted_Connection = true or Integrated Security=SSPI&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here &lt;b&gt;SSPI- Security Support Provider Interface.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
DSN:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;This attribute is required while connecting with data sources using &lt;b&gt;ODBC Drivers.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Examples for Sql Server and Oracle Connection Strings:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Oracle Connection String:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&quot;Provider=Msdaora;User Id=Scott;Password=tiger [;Data Source=&lt;server&gt;]&quot;&lt;/server&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Sql Server Connection String:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Sql Server Authentication :- &lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&quot;Provider=SqlOledb;User Id=Sa;Password=&lt;pwd&gt;;&lt;br /&gt;Database=&lt;db name=&quot;&quot;&gt;[;Data Source=&lt;server&gt;]&quot;&lt;/server&gt;&lt;/db&gt;&lt;/pwd&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Windows Authentication:-&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&quot;Provider=SqlOledb;Trusted_Connection= true / Integrated Security = SSPI;&lt;br /&gt;Database=&lt;db name=&quot;&quot;&gt;[;Data Source=&lt;server&gt;]&quot;&lt;/server&gt;&lt;/db&gt;&lt;/h4&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you are Clear about &lt;b&gt;Setting Connection string for Sql Server and Oracle databases.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Don&#39;t forget to comment and share if you like this post for our friends. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/pages/Aspdotnet-Sekhars/483754201696269&quot; data-layout=&quot;button_count&quot; data-send=&quot;false&quot; data-show-faces=&quot;false&quot; data-width=&quot;50&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/2099481962847241959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/connection-string-parameters-for-sql-database-oralce-database-with-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2099481962847241959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2099481962847241959'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/connection-string-parameters-for-sql-database-oralce-database-with-example.html' title='Connection string parameters for Sql database and Oracle database with Example'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-1695246080935574563</id><published>2013-08-06T10:12:00.000+05:30</published><updated>2015-01-17T01:05:13.737+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Ado.Net"/><title type='text'>Ado.Net Tutorial: Introduction to Ado.Net- Part2 Sending SqlCommand object and Getting Result using DataReader.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction to Ado.Net:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This is Second Part of &lt;b&gt;Ado.Net Introduction part1&lt;/b&gt;. In the first part i explained&lt;b&gt; Basics of Ado.Net and How to Establish Connection With Database.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Now in this part we will see&lt;b&gt; how to send request using Sql Command Object and How to Get the Result from Database using DataReader Object.&lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
2). Sending Request as an Sql Statement:&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
So After &lt;b&gt;Establishing Connection&lt;/b&gt; with the Database next step is &lt;b&gt;sending a request as an Sql Statement.&lt;/b&gt;We will use &lt;b&gt;command object&lt;/b&gt; to do this thing.&lt;b&gt; Command Object&lt;/b&gt; have following &lt;b&gt;Constructors.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&amp;nbsp; Command( )&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Command(string CommandText, Connection Conn)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CommandText: &lt;/b&gt;Here Command Text means any sql statement like &lt;b&gt;select,insert,update,delete statements or Stored Procedure&lt;/b&gt; name.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Properties:&lt;/h4&gt;
&lt;b&gt;Connection:&lt;/b&gt; Gets or Sets the Connection associated with the Command Object.&lt;br /&gt;
&lt;b&gt;CommandText &lt;/b&gt;: Gets or Sets the Sql Statement Associated with the Command Object.&lt;br /&gt;
&lt;br /&gt;
We can create the Command Object in the following manner&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;10&quot;&gt;Connection Con=new Connection(string ConnectionString);
Command ObjCmd=new Command();
ObjCmd.CommandText=&quot;Sql Statement/Stored Procedure&quot;;
ObjCmd.Connection=Con;

or
string ConnectionString=&quot; Credentials&quot;;
string SqlStatement=&quot;Some Statement&quot;;
Connection Con=new Connection(ConnectionString);
Command ObjCmd=new Command(SqlStatement,Con);


&lt;/textarea&gt;&lt;br /&gt;
Note: One thing you should remember here i.e You have to prefix the data provider api prefix before Connection and Command Classes.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;3). Capturing Results given by the data source: &lt;/h4&gt;
Now we completed step2 of &lt;b&gt;Sending request as an Sql Statement.&lt;/b&gt; Now our next step is to&lt;b&gt; Get the result using Sql Statement in the Command Object. &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Command Object &lt;/b&gt;itself have the methods to capture the results. These are&lt;br /&gt;
&lt;br /&gt;
- Call&lt;b&gt; ExecuteReader( )&lt;/b&gt; method to Execute the Select statement in Command Object which returns data as &lt;b&gt;Rows and Columns&lt;/b&gt;. This method returns &lt;b&gt;an object of class DataReader&lt;/b&gt; which contains data that is retrieved from data source in the form of&lt;b&gt; rows and columns.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
-Call &lt;b&gt;ExecuteScalar()&lt;/b&gt; method when we want to execute a &lt;b&gt;Select Statement&lt;/b&gt; that returns a &lt;b&gt;single value result.&lt;/b&gt; The method returns result of the query in the form of a &lt;b&gt;object.&lt;/b&gt; We have to cast it our required type later.&lt;br /&gt;
&lt;br /&gt;
-Call &lt;b&gt;ExecuteNonQuery( )&lt;/b&gt; method when we want to &lt;b&gt;execute any Statement other than select, like Insert, Update, Delete&lt;/b&gt; etc. The method &lt;b&gt;returns a numeric value&lt;/b&gt; telling the number of rows affected by the statement.&lt;br /&gt;
&lt;br /&gt;
So Calling one of above three methods to capture the results is our third step. &lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Next step is to retrieve the data from Data Reader:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;DataReader class&lt;/b&gt; holds the data in the form&lt;b&gt; Rows and Columns.&lt;/b&gt; To access data from this &lt;b&gt;DataReader &lt;/b&gt;it provides methods. They are&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;GetName(int ColumnIndex):&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Returns the Name of Column in the Specified Column Index. Here Return type is String.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Read( ):&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If we call this method, it moves the record pointer to next record in datareader object. It&lt;b&gt; returns true if datareader object contains data in the next row, returns false if it contains no data.&lt;/b&gt; Return type is boolean.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;GetValue(int ColumnIndex ):&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
We use this method to get the &lt;b&gt;Column values&lt;/b&gt; from the &lt;b&gt;row pointer is Pointing.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
We can access the row pointer in the following ways&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DR[Column Index]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return Object Type&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DR[Column Name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return Type is Object&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;GetNextResult( ):&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; Suppose if your &lt;b&gt;Select Statement&lt;/b&gt; returns multiple tables then we need to move between tables to access them. So &lt;b&gt;GetNextResult( )&lt;/b&gt; method used to &lt;b&gt;move the pointer to next table in DataReader object.&lt;/b&gt; It &lt;b&gt;returns&amp;nbsp; true if the Datareader object contains table else returns false.&lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you got full pledge information on &lt;b&gt;Introduction to Ado.Net and Ado.Net Object Communication Model. &lt;/b&gt;In later sessions we will see &lt;b&gt;how to establish Connection with Sql Server Database, How to work with SqlCommand Object ,How to retrieve Data From DataReader with Example.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Don&#39;t Forget to Comment and Share if you like this post for our friends. Let me know if you have any other requirement. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/1695246080935574563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/Introdution-to-ado.net-part2-sendings-SqlCommand-Object-Getting-Result-back-using-DataReader.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1695246080935574563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/1695246080935574563'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/Introdution-to-ado.net-part2-sendings-SqlCommand-Object-Getting-Result-back-using-DataReader.html' title='Ado.Net Tutorial: Introduction to Ado.Net- Part2 Sending SqlCommand object and Getting Result using DataReader.'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4968988916630923865</id><published>2013-08-05T21:03:00.000+05:30</published><updated>2013-08-06T20:34:42.015+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Ado.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="Connection String"/><title type='text'>Ado.Net Tutorials: Introduction to Ado.Net - Part1 Establishing Connection with DataBase</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction to ADO.NET:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If you are new to&lt;b&gt; .Net Technologies, &lt;/b&gt;want to get job in .net then start learning&lt;b&gt; basics oops concepts&lt;/b&gt; and then&lt;b&gt; learn Ado.Net Tutorials.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; This article will give you brief&lt;b&gt; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html&quot; target=&quot;_blank&quot;&gt;introduction to ADO.NET&lt;/a&gt;&lt;/b&gt; in&lt;b&gt; .NET&lt;/b&gt; like&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;What is Ado.Net,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;What Ado.Net Provides you to communicate with data sources,&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;What are the providers provided by Ado.Net to Communicate with Data Sources like Flat Files(Text Files,XML FIles etc), Databases(Oracle, Sql Server, DB2, Teradata, MySql, Ms Access, etc),&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Architecture of Ado.Net, Object Model of Ado.Net,&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&amp;nbsp;How to perform CRUD operations on Databases &lt;/b&gt;etc things. &amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It is a &lt;b&gt;set of libraries&lt;/b&gt; included in &lt;b&gt;Mircrosoft .Net Framework&lt;/b&gt; for&lt;b&gt; Data Source communication&lt;/b&gt; from &lt;b&gt;.Net Applications&lt;/b&gt;. These libraries are in the form of &lt;b&gt;Drivers&lt;/b&gt; and &lt;b&gt;Data Providers&lt;/b&gt;. &lt;b&gt;Ado.Net&lt;/b&gt; was designed as an extension for older &lt;b&gt;ADO&lt;/b&gt; which is unmanaged.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
The following are the &lt;b&gt;Data Providers&lt;/b&gt; provided by &lt;b&gt;Ado.Net&lt;/b&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;ODBC Data Provider.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Oledb Data Provider.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Oracle Data Provider.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Sql Data Provider.&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
ODBC Data Provider:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This &lt;b&gt;Data Provider&lt;/b&gt; used for communicating with &lt;b&gt;data sources&lt;/b&gt; using &lt;b&gt;ODBC interface&lt;/b&gt;.&lt;br /&gt;
These data sources are older one.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;API Prefix&lt;/b&gt; is: &lt;b&gt;Odbc&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Namespace:&lt;/b&gt; &lt;b&gt;System.Data.Odbc.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Oledb Data Provider:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This &lt;b&gt;Data Provider &lt;/b&gt;used for communicating with &lt;b&gt;data sources &lt;/b&gt;like &lt;b&gt;Files, Databases,Indexing servers &lt;/b&gt;etc.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;API Prefix&lt;/b&gt; is: &lt;b&gt;Oledb&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Namespace: System.Data.Oledb.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Oracle Data Provider:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This &lt;b&gt;Data Provider&lt;/b&gt; used for communicating with only &lt;b&gt;Oracle Database&lt;/b&gt; using &lt;b&gt;OracleClient Provider.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;API Prefix&lt;/b&gt;: &lt;b&gt;OracleClient.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Namespace:&lt;/b&gt; &lt;b&gt;System.Data.OracleClient.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Sql Data Provider:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This &lt;b&gt;Data Provider&lt;/b&gt; used for communicating with only &lt;b&gt;Sql Server Database &lt;/b&gt;using &lt;b&gt;SqlClient Provider.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;API Prefix:&lt;/b&gt; &lt;b&gt;SqlClient.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Namespace:&lt;/b&gt; &lt;b&gt;System.Data.SqlClient.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;System.Data,System.Data.Oledb, System.Data.SqlClient, System.Data.Odbc&lt;/b&gt; all these namespaces are defined under same &lt;b&gt;assembly&lt;/b&gt; i.e &lt;b&gt;System.Data.dll&lt;/b&gt; where as &lt;b&gt;System.Data.OracleClient namespace&lt;/b&gt; defined in &lt;b&gt;System.Data.OracleClient.dll Assembly.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
All the above four namespaces contains same set of classes as follows : &lt;b&gt;Connection, Command, DataReader, DataAdapter, CommandBuilder, Parameter&lt;/b&gt; etc.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
To discriminate between each other these class names are prefixed by their&lt;b&gt; API Prefixes&lt;/b&gt; Such as&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;b&gt;&amp;nbsp; OdbcConnection &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OdbcCommand&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SqlConnection &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SqlCommand&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OledbConnection &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; OledbCommand&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OracleConnection &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; OracleCommand.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Most of the &lt;b&gt;.Net Applications&lt;/b&gt; Use Database as &lt;b&gt;Sql Server&lt;/b&gt; So we will go deeply on &lt;b&gt;How to Communicate with Sql Server using SqlClient Data Provider.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If you want to see how this &lt;b&gt;Data Providers Communicate with Data Stores&lt;/b&gt; then look at the below diagram.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-LaPhklS1Go4/Uf-yv9H2ugI/AAAAAAAAAVk/4ZITaiM_fJc/s1600/Ado.Net+Object+Communication+with+DataSources.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Communicating with Ado.Net Data Objects&quot; border=&quot;0&quot; height=&quot;372&quot; src=&quot;http://4.bp.blogspot.com/-LaPhklS1Go4/Uf-yv9H2ugI/AAAAAAAAAVk/4ZITaiM_fJc/s640/Ado.Net+Object+Communication+with+DataSources.png&quot; title=&quot;Ado.Net Data Providers Communication&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If you see the &lt;b&gt;Ado.Net Object Communication System&lt;/b&gt; in the above image you find that it requires three steps to communicate with Data Stores.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
1). &lt;b&gt;Establishing a Connection with Database or Data Store Connection Object.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
2). &lt;b&gt;Sending Request i.e in the form of Sql Statement using Command ,Adapter objects.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
3). &lt;b&gt;Receiving result using Reader Object or DataSet Object.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Establishing Connection with DataStore:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;To Interact with &lt;b&gt;Database&lt;/b&gt; we must have &lt;b&gt;connection&lt;/b&gt; with it. We use &lt;b&gt;Connection Object&lt;/b&gt; to Establish a channel between database and client for communication.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This Connection Object have following Constructors i.e&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; Connection( )&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Connection( string ConnectionString)&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;ConnectionString&lt;/b&gt; is a collection of attributes that are necessary for connecting with a DataSource, those are:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;b&gt;Provider&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Data Source&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -User Id &amp;amp; Password&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Database or Initial Catalog&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -Trusted_Connection or Integrated Security&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -DSN&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Provider: &lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Provider is required for connecting with any Data Store. we have to use different provider for each Data Store.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Oracle&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Msdaora&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Sql Server&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlOledb&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;MS-Access or MS-Excel&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Microsoft.Jet.Oledb.4.0&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;MS-Indexing Server&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Msidxs &lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Data Source:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It is the name of the machine on which the Data Source exist. If the Data Source exist in the local machine then it is optional. If Data Source exist in remote machine then we have to mention it in Connection String.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
User Id and Password:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As Database&#39;s are Secured with Roles and Users, then it is necessary to mention the User Id and Password in the Connection String.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sql Server&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sa/&lt;pwd&gt;&lt;password&gt;&lt;password&gt;&lt;/password&gt;&lt;/password&gt;&lt;/pwd&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Oracle&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scott/tiger&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Database or Initial Catalog:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As a single Data Source may contain multiple Databases then it is necessary to mention the Database name in Connection String. These attributes used only for connecting with &lt;b&gt;Sql Server Database.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Trusted_Connection or Integrated Security:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
These credentials are used for Security purposes while connecting with &lt;b&gt;Sql Server Database&lt;/b&gt; in &lt;b&gt;windows authentication mode.&amp;nbsp;&lt;/b&gt; If you use &lt;b&gt;Windows Authentication Mode&lt;/b&gt; by specifying these credentials then no need to mention the &lt;b&gt;User Id and Password in Connection String.&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
DSN:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
These Attributes are required while connecting with data stores using ODBC Providers.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Connection String for Oralce:&lt;/h4&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;3&quot;&gt;&quot;Provider=Msdaora;User Id=Scott;Password=tiger [;Data Source=&lt;server&gt;]&quot;
&lt;/textarea&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Connection String for Sql Server:&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;10&quot;&gt;&quot;Provider=SqlOledb;User Id=Sa;Password=&lt;pwd&gt;;
Database=&lt;db name&gt;[;Data Source=&lt;server&gt;]&quot;

In case Windows Authentication

&quot;Provider=SqlOledb;Trusted_Connection= true/ Integrated Security=SSPI;
Database=&lt;db name&gt;[;Data Source=&lt;server&gt;]&quot;

SSPI: Security Support Provider Interface.
&lt;/textarea&gt;

&lt;/h4&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Members of Connection Class:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
1. Open( ): Opens the Connection with Data Store or Database.&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
2. Close( ):&amp;nbsp; Closes the Connection that is Open.&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
3. State: Gets the Status of the Connection.&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
4. ConnectionString: Gets or Sets the Connection String Associated with the Connection Object.&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
We can create the connection Object as follows&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt;Connnection ObjCon= new Connection();
ObjCon.ConnectionString = &quot;&lt;connection String&gt;&quot;;
          or
Connection ObjCon = new Connection(&quot;&lt;connection String&gt;&quot;);&lt;/textarea&gt;


&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
You can also learn &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/connection-string-parameters-for-sql-database-oralce-database-with-example.html&quot; target=&quot;_blank&quot;&gt;What are the different parameters for Connection String&lt;/a&gt; and&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/how-to-set-connection-string-for-sqlconnection-to-connect-to-sql-database-example-csharp.html&quot; target=&quot;_blank&quot;&gt; How to set Connection for SqlConnection Object to Connect to Sql Server database.&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope You clear about things like &lt;b&gt;what is Ado.Net, What are the Providers that Ado.Net Provides, How to communicate with data sources ,how to establish Connection with&amp;nbsp; DataSources.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; In this part we saw only Only&lt;b&gt; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html&quot; target=&quot;_blank&quot;&gt;How to create a Connection between Application and Database&lt;/a&gt;&lt;/b&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html&quot; target=&quot;_blank&quot;&gt;,&lt;/a&gt; So in the Second Part I will Cover remaining two things i.e&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/08/Introdution-to-ado.net-part2-sendings-SqlCommand-Object-Getting-Result-back-using-DataReader.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt; how to send a request as Sql Statement, and How to receive Result. &lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Don&#39;t Forget to Comment and Share for our friends if you like this Post. &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4968988916630923865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4968988916630923865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4968988916630923865'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/08/ado.net-tutorials-introduction-ado.net-beginners-Esatablishing-connection-with-Database-pdf.html' title='Ado.Net Tutorials: Introduction to Ado.Net - Part1 Establishing Connection with DataBase'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-LaPhklS1Go4/Uf-yv9H2ugI/AAAAAAAAAVk/4ZITaiM_fJc/s72-c/Ado.Net+Object+Communication+with+DataSources.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-6210030438129878535</id><published>2013-07-30T19:19:00.001+05:30</published><updated>2015-01-17T01:05:47.443+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Markup Extensions"/><category scheme="http://www.blogger.com/atom/ns#" term="Static Resource example"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><title type='text'>WPF Tutorial: Markup Extensions - XAML based and WPF based Markup Extensions, How to use Markup extensions for binding elements in WPF </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Markup Extensions in WPF:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my previous articles i explained many articles on &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Asp.Net&quot; target=&quot;_blank&quot;&gt;Asp.Net&lt;/a&gt; ,&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/OopsConcepts&quot; target=&quot;_blank&quot;&gt;Oops Concepts&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF.&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp; Now we will see one successive &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF Tutorials&lt;/a&gt; i.e Markup Extensions in WPF.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Markup Extensions:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Markup Extensions&lt;/b&gt; are used to &lt;b&gt;assign complex values&lt;/b&gt; to &lt;b&gt;properties in XAML&lt;/b&gt; which are not possible using markup language. These markup extensions are enclosed in braces{} and keyword immeadiatly followed by&amp;nbsp; the left brace, indicates which markup extensions you are using. For the markup extension you can set &lt;b&gt;one or more properties.&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Syntax:&lt;/b&gt;&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;3&quot;&gt;{&lt;markup extension&gt; prop1=value1, prop2=value2}&lt;/textarea&gt; &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;Markup Extension&lt;/b&gt;s are classified into two categories.&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;XAML based Markup Extensions&amp;nbsp;&lt;/li&gt;
&lt;li&gt;WPF based Markup Extensions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
XAML based Markup Extensions:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
These are the&lt;b&gt; markup extensions&lt;/b&gt; that can be used in &lt;b&gt;XAML&lt;/b&gt; but not possible to implement them through&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;C#.Net&lt;/b&gt; code as they have no classes in &lt;b&gt;.Net Framework.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
The following are &lt;b&gt;XAML based Markup Extensions&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;{x:null}&lt;/span&gt;&lt;/b&gt; - Used to &lt;b&gt;assign null to a property&lt;/b&gt; using &lt;b&gt;XAML&lt;/b&gt; markup.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;{x:Type}&lt;/span&gt;&lt;/b&gt; - Used to specify the &lt;b&gt;type of element&lt;/b&gt; in &lt;b&gt;XAML&lt;/b&gt; markup.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;{x:Type&lt;type&gt; &lt;type&gt;}&lt;/type&gt;&lt;/type&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;{x:Array}&lt;/b&gt;&lt;/span&gt; - Used to &lt;b&gt;declare an array&lt;/b&gt; with in a &lt;b&gt;XAML&lt;/b&gt; markup.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;{x:Static}&lt;/b&gt;&lt;/span&gt; - Used to &lt;b&gt;assign a static collection to a property&lt;/b&gt; of the &lt;b&gt;control.&lt;/b&gt;&lt;/div&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;7&quot;&gt; &lt;grid&gt;
        &lt;listbox Height=&quot;142&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;178,114,0,0&quot; ItemsSource=&quot;{x:Static Fonts.SystemFontFamilies}&quot; Foreground=&quot;Blue&quot; FontWeight=&quot;Bold&quot; Name=&quot;listBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;211&quot; /&gt;
    &lt;/Grid&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
WPF based Markup Extensions:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
These are &lt;b&gt;markup extensions&lt;/b&gt; that can be used in &lt;b&gt;XAML&lt;/b&gt; an also &lt;b&gt;C#.Net &lt;/b&gt;code as they have classes in &lt;b&gt;.Net Framework.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;StaticResource :&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Used to &lt;b&gt;bind a style or Resource&lt;/b&gt; during &lt;b&gt;compilation&lt;/b&gt; to use this &lt;b&gt;Markup Extension&lt;/b&gt; in &lt;b&gt;XAML&lt;/b&gt;, use the&amp;nbsp; following syntax.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;{StaticResource Resource Key =&lt;key&gt;}&lt;br /&gt;{StaticResource &lt;key&gt;}&lt;/key&gt;&lt;/key&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Dynamic Resource:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;This is same as&lt;b&gt; static resource &lt;/b&gt;except that it will&lt;b&gt; bind&lt;/b&gt; the &lt;b&gt;specified resource&lt;/b&gt; or&lt;b&gt; style dynamically&lt;/b&gt; at run time and not during&lt;b&gt; compilation.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
To use this markup extension in&lt;b&gt; XAML syntax&lt;/b&gt; is as follows&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&lt;br /&gt;{DynamicResource ResourceKey=&lt;key&gt;}&lt;br /&gt;{DynamicResource &lt;key&gt;}&lt;/key&gt;&lt;/key&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;Binding:&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Used to &lt;b&gt;Bind&lt;/b&gt; one control to another control. &lt;b&gt;WPF&lt;/b&gt; support a feature called&lt;b&gt; data binding&lt;/b&gt; which is &lt;br /&gt;
implemented using this &lt;b&gt;Markup Extensions&lt;/b&gt;.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;span style=&quot;color: blue;&quot;&gt;Elementname and Path.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ElementName &lt;/b&gt;property is used to specify name of the control to which you want to bind and &lt;b&gt;Path&lt;/b&gt; is used&lt;br /&gt;
to specify &lt;b&gt;property&lt;/b&gt; name of the control to which you want to &lt;b&gt;bind.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
It has property&lt;b&gt; mode&lt;/b&gt; also to specify whether the Binding is &lt;b&gt;oneway/twoway.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
The following example takes two textboxes and a slider and &lt;b&gt;Bind FontSize Property&lt;/b&gt; of one TextBox and &lt;b&gt;Text Property&lt;/b&gt; of another TextBox to the value of the&lt;b&gt; slider using Binding Markup Extension.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; Add a window to the project and design as follows with a &lt;b&gt;slider&lt;/b&gt; and two Textboxes by &lt;b&gt;binding&lt;/b&gt; &lt;b&gt;FontSize&lt;/b&gt; Property of the first Textbox and &lt;b&gt;Text&lt;/b&gt; property of the another Textbox to the value of the slider as below.&amp;nbsp; &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;10&quot;&gt; &lt;grid&gt;
        &lt;textbox Height=&quot;120&quot; HorizontalAlignment=&quot;Left&quot; Text=&quot;Aspdotnet-sekhar Blog&quot; FontSize=&quot;{Binding ElementName=slider1,Path=Value}&quot; Margin=&quot;196,12,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;417&quot; /&gt;
        &lt;textbox Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Text=&quot;{Binding ElementName=slider1,Path=Value}&quot; Margin=&quot;209,163,0,0&quot; Name=&quot;textBox2&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;120&quot; /&gt;
        &lt;slider Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;242,224,0,0&quot; Name=&quot;slider1&quot; TickFrequency=&quot;5&quot; TickPlacement=&quot;BottomRight&quot; Minimum=&quot;15&quot; Maximum=&quot;100&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;452&quot; /&gt;
    &lt;/Grid&gt;



&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
You can find Tutorial for above Markup Extension Binding Example &lt;a href=&quot;http://www.youtube.com/watch?v=Jc5vpm2e_RM&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/Jc5vpm2e_RM&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
In the above example at&lt;b&gt; runtime &lt;/b&gt;when you move the &lt;b&gt;slider&lt;/b&gt; automatically the &lt;b&gt;font size&lt;/b&gt; of the 1st textbox will change and also the&lt;b&gt; value&lt;/b&gt; displayed in the 2nd textbox which is current value of the&lt;b&gt; slider.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
When you change the value of in 2nd textbox and press the tab then automatically value of the&lt;b&gt; slider&lt;/b&gt; also changed because by &lt;b&gt;default mode property&lt;/b&gt; of binding markup extension is set to&lt;b&gt; twoway.&lt;/b&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you got clear idea on &lt;b&gt;WPF Markup Extensions.&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This article is the one successive &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF Tutorials&amp;nbsp; &lt;/a&gt;i.e&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt;What is WPF and its features&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;&amp;nbsp; Architecture of WPF&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/WPF-vs-Windows-Forms-difference-between-wpf-windows-forms-in-events-properites-methods-for-control.html&quot; target=&quot;_blank&quot;&gt;Windows Forms vs Windows Presentation Foundation&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.com/2013/07/what-is-xaml-File-compilation-process-attribute-property-element-Syntaxes.html&quot; target=&quot;_blank&quot;&gt; What is XAML and its parts&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/Tutorial-Markup-Extensions-XAML-based-and-WPF-based-example-binding-Csharp.Net.html&quot; target=&quot;_blank&quot;&gt;XAML Markup Extensions&lt;/a&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt; etc.&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Don&#39;t forget to comment and share for our friends if like this post. Thank You.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/6210030438129878535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/Tutorial-Markup-Extensions-XAML-based-and-WPF-based-example-binding-Csharp.Net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/6210030438129878535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/6210030438129878535'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/Tutorial-Markup-Extensions-XAML-based-and-WPF-based-example-binding-Csharp.Net.html' title='WPF Tutorial: Markup Extensions - XAML based and WPF based Markup Extensions, How to use Markup extensions for binding elements in WPF '/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4048776445643500649</id><published>2013-07-28T09:46:00.001+05:30</published><updated>2015-01-18T10:04:55.746+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Attribute Syntx"/><category scheme="http://www.blogger.com/atom/ns#" term="code behind"/><category scheme="http://www.blogger.com/atom/ns#" term="Property Element Syntax"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML"/><category scheme="http://www.blogger.com/atom/ns#" term="XAML file Compilation"/><title type='text'>WPF Tutorial: What is XAML?, XAML and Codebehind, Attribute and Property Element Syntax, XAML File Compilation Process</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Introduction to XAML, Attribute and Property Element Syntax, XAML File Compilation Process&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my previous articles i explained various articles on &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Asp.Net&quot; target=&quot;_blank&quot;&gt;Asp.Net&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/OopsConcepts&quot; target=&quot;_blank&quot;&gt;Oops Concepts.&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Now we will see&lt;b&gt; importance of XAML in WPF, XAML vs Codebehind, Benefits of Attribute and Property Element Syntax and how the xaml file compiles. You can find other &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF Tutorials here.&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
What is XAML?&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;b&gt; XAML&lt;/b&gt; called as &lt;b&gt;Zammel&lt;/b&gt; stands for &lt;b&gt;Extensible Markup Language.&lt;/b&gt; It is declarative language based on XML. It allows us to &lt;b&gt;create UI declaratively&lt;/b&gt; which are visible.&amp;nbsp; It gives flexibility to work individuals on designing and programming at a time. This was introduced in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;wpf&lt;/b&gt;&lt;/a&gt; and also used in &lt;b&gt;Silverlight&lt;/b&gt; and &lt;b&gt;WF&lt;/b&gt; and other technologies which supports&lt;b&gt; XAML&lt;/b&gt;. &lt;b&gt;XAML&lt;/b&gt; and along with it&#39;s &lt;b&gt;powerful binding techniques&lt;/b&gt; we can create WPF Applications with less code written.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; XAML vs Codebehind:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Writing Code with &lt;b&gt;XAML&lt;/b&gt; is when compare to code behind file.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;5&quot;&gt;    
&lt;grid&gt;
        &lt;button Name=&quot;Btn1&quot; Content=&quot;Button&quot; Height=&quot;30&quot; Width=&quot;90&quot;/&gt;
    &lt;/Grid&gt;
&lt;/textarea&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;For the above &lt;b&gt;XAML&lt;/b&gt; we can write it in code behind file as below&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;  Grid Obj = new Grid();
            Button btn = new Button();
            btn.Name = &quot;Btn1&quot;;
            btn.Content = &quot;Clck Me&quot;;
            btn.Width = 150;
            btn.Height = 50;
            Grid.SetColumn(btn, 0);
            Grid.SetRow(btn, 0);
            Obj.Children.Add(btn);
            this.AddChild(Obj);
&lt;/textarea&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Attribute Syntax and Property Element Syntax:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In &lt;b&gt;XAML&lt;/b&gt; we can write the code in two ways. i.e&amp;nbsp; &lt;b&gt;Attribute Syntax&lt;/b&gt; and &lt;b&gt;Property Element Syntax.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Some times it is not possible to specify the property values using &lt;b&gt;Attribute Syntax&lt;/b&gt; in that cases We can use &lt;b&gt;Property Element Syntax.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Attribute Syntax and Property Element Syntax:&lt;/b&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;/h4&gt;
&lt;/div&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt;        &lt;!--Property Syntax--&gt;
        &lt;button Name=&quot;Btn1&quot; Content=&quot;Button&quot; Height=&quot;30&quot; Width=&quot;90&quot; Background=&quot;LightBlue&quot;/&gt;
        
        &lt;!--Attribute Element Syntax--&gt;
        &lt;button&gt;
            &lt;Button.Content&gt;Click Me&lt;/Button.Content&gt;
            &lt;Button.Width&gt;150&lt;/Button.Width&gt;
            &lt;Button.Height&gt;40&lt;/Button.Height&gt;
            &lt;Button.Background&gt;
                &lt;lineargradientbrush&gt;
                    &lt;gradientstop Color=&quot;Red&quot; Offset=&quot;1&quot;/&gt;
                    &lt;gradientstop Color=&quot;Blue&quot; Offset=&quot;.1&quot;/&gt;
                &lt;/LinearGradientBrush&gt;
            &lt;/Button.Background&gt;
        &lt;/Button&gt;

&lt;/textarea&gt;

&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;In the above case it is not possible to set background as &lt;b&gt;LinearGradientBrush&lt;/b&gt; using &lt;b&gt;Property Syntax&lt;/b&gt; so in this case you have to use &lt;b&gt;Attribute Element Syntax &lt;/b&gt;as Above.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
XAML File Compilation Process:&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Every &lt;b&gt;XAML&lt;/b&gt; file contains two files i.e&lt;b&gt; XAML&lt;/b&gt; and &lt;b&gt;XAML.CS&lt;/b&gt; files. When you &lt;b&gt;compile&lt;/b&gt; your application it will first &lt;b&gt;Converts XAML file into BAML&lt;/b&gt; and&lt;b&gt; cs file into g.cs.&lt;/b&gt; For eg your application contains window1.xaml and window1.xaml.cs then compiler converts it to &lt;b&gt;window1.baml&lt;/b&gt; and&lt;b&gt; window1.g.cs&lt;/b&gt; files. &lt;b&gt;BAML&lt;/b&gt; stands for &lt;b&gt;Binary Applicaton markup Language&lt;/b&gt; and&lt;b&gt; g stands for generated.&lt;/b&gt; &lt;b&gt;Compiler&lt;/b&gt; uses &lt;b&gt;BAML and g.cs&lt;/b&gt; file to generate &lt;b&gt;executable files.&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;BAML&lt;/b&gt; is&lt;b&gt; compiled version of XAML&lt;/b&gt; so it&#39;s not humarn readable format but it is more effcient for &lt;b&gt;loading&lt;/b&gt; and&lt;b&gt; parsing&lt;/b&gt; at &lt;b&gt;runtme. BAML&lt;/b&gt; files are optimized for faster loading at runtime. The&lt;b&gt; g.cs&lt;/b&gt; file code to load &lt;b&gt;BAML from executable&lt;/b&gt; and create &lt;b&gt;UI&lt;/b&gt;. These both fles are stored in Obj\Debug and Obj\Release folder of application&#39;s local folder respectively.&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Reference&lt;/b&gt; :http://msdn.microsoft.com/en-us/library/ms752059.aspx&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope you got overview on&lt;b&gt; what is xaml, how xaml file compiles, Attribute Syntax vs Property Element Syntax.&lt;/b&gt; It is One of Successive &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF Tutorials,&lt;/a&gt; You can find other &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt;WPF Tutorials here&lt;/a&gt;. &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and Share for our friends if&amp;nbsp; you like this post. Thank You.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel="related" href="http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html" title="WPF Tutorial: What is XAML?, XAML and Codebehind, Attribute and Property Element Syntax, XAML File Compilation Process"/><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4048776445643500649/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/what-is-xaml-File-compilation-process-attribute-property-element-Syntaxes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4048776445643500649'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4048776445643500649'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/what-is-xaml-File-compilation-process-attribute-property-element-Syntaxes.html' title='WPF Tutorial: What is XAML?, XAML and Codebehind, Attribute and Property Element Syntax, XAML File Compilation Process'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-7036968399950836469</id><published>2013-07-26T12:09:00.000+05:30</published><updated>2015-01-18T10:05:12.178+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Animation Examples"/><category scheme="http://www.blogger.com/atom/ns#" term="DoubleAnimation"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>WPF Animation: Moving a line from top to bottom using wpf doubleanimation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Moving a line using WPF DoubleAnimation:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my previous articles i had explained various articles on&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/p/blog-page_21.html&quot; target=&quot;_blank&quot;&gt; WPF&lt;/a&gt; , &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Asp.Net&quot; target=&quot;_blank&quot;&gt;Asp.Net&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/OopsConcepts&quot; target=&quot;_blank&quot;&gt;Oops Concepts&lt;/a&gt;. Now we will see a &lt;b&gt;simple example on how to move a line from top to bottom using WPF DoubleAnimation.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; If you are &lt;b&gt;new to WPF animation&lt;/b&gt;, If you want to &lt;b&gt;move an element in wpf applications&lt;/b&gt; then this example will help you.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In &lt;b&gt;WPF Three types of Animations&lt;/b&gt; are available.&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;From/To/By Animations&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Key Frame Animations.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Path Animations.&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
In &lt;b&gt;From/To/By Animations&lt;/b&gt; we will specify the &lt;b&gt;from, To or By values&lt;/b&gt; , Based on these values animation occurs. We use &lt;b&gt;From/To/By Animation to move a line from top to bottom.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
First take a window in &lt;b&gt;wpf&lt;/b&gt; project and then &lt;b&gt;draw a horizontal line&lt;/b&gt; using following &lt;b&gt;syntax.&lt;/b&gt;&amp;nbsp; You can find more details on &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/04/basic-drawings-and-shapes-in-WPF-using-xaml-tags.html&quot; target=&quot;_blank&quot;&gt;how to draw basic shapes and drawings in wpf.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;html&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;10&quot;&gt;&lt;window x:Class=&quot;WpfApplication1.Animating_Line_in_WPF&quot;
        xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
        Title=&quot;Animating_Line_in_WPF&quot; Height=&quot;600&quot; Width=&quot;800&quot; Loaded=&quot;Window_Loaded&quot;&gt;
    &lt;canvas&gt;
        &lt;line  Name=&quot;Ln&quot; X1=&quot;10&quot; Y1=&quot;100&quot; X2=&quot;300&quot; Y2=&quot;100&quot;  StrokeThickness=&quot;5&quot; Stroke=&quot;Red&quot; Canvas.Left=&quot;135&quot; Canvas.Top=&quot;8&quot; /&gt;
    &lt;/Canvas&gt;
&lt;/Window&gt;

&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
In the above code we used &lt;b&gt;line element to draw a line by specifying starting point(X1,Y1) and Ending Point(X2,Y2) and it is stroked with red color with thickness 5.&lt;/b&gt; It is placed as a&lt;b&gt; child&lt;/b&gt; in a &lt;b&gt;Canvas.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now our task is&lt;b&gt; to move this line element from top to bottom&lt;/b&gt;. Now in the &lt;b&gt;Window Load event&lt;/b&gt; write below code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;15&quot;&gt; private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Demonstrates the From and To properties used together. 
            // Animates the lines canvas.top property from 50 to 300 over 10 seconds.
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 50;
            myDoubleAnimation.To = 300;
            myDoubleAnimation.Duration =
                new Duration(TimeSpan.FromSeconds(10));
            myDoubleAnimation.AutoReverse = true;
            myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard.SetTargetName(myDoubleAnimation, &quot;Ln&quot;);
            Storyboard.SetTargetProperty(myDoubleAnimation,
                new PropertyPath(Canvas.TopProperty));
            Storyboard myStoryboard = new Storyboard();
            myStoryboard.Children.Add(myDoubleAnimation);
            myStoryboard.Begin(Ln);
        }
&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Above code first we created a &lt;b&gt;DoubleAnimation&lt;/b&gt; and assigned values for &lt;b&gt;From ,To,Duration,AutoReverse and RepeatBehaviour.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Next to Apply this &lt;b&gt;double animation&lt;/b&gt; to&lt;b&gt; an element&lt;/b&gt; we have to use &lt;b&gt;storyboard&lt;/b&gt; and &lt;b&gt;set Target Name and Target Property and doubleanimation as child for storyboard.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;StoryBoard&lt;/b&gt; has three events such&lt;b&gt; Begin(), Pause(), and Stop()&lt;/b&gt; to control Animation.&lt;br /&gt;
&lt;br /&gt;
See How it works&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-pVyq3td_9Bs/UfIXStOnZGI/AAAAAAAAAU0/wzaMLToNhWg/s1600/Animate.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-pVyq3td_9Bs/UfIXStOnZGI/AAAAAAAAAU0/wzaMLToNhWg/s1600/Animate.gif&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Moving Line from top to bottom using DoubleAnimation&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
I hope this will help to you&lt;b&gt; to move an element in wpf&lt;/b&gt;. Later i will explain more &lt;b&gt;animation examples.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; Don&#39;t forget to Comment and Share for our friends if you like this post. Thank You.&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/7036968399950836469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/wpf-animation-move-an-element-line-from-top-to-bottom-using-doubleanimation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/7036968399950836469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/7036968399950836469'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/wpf-animation-move-an-element-line-from-top-to-bottom-using-doubleanimation.html' title='WPF Animation: Moving a line from top to bottom using wpf doubleanimation'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-pVyq3td_9Bs/UfIXStOnZGI/AAAAAAAAAU0/wzaMLToNhWg/s72-c/Animate.gif" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-4521195164581430527</id><published>2013-07-19T20:29:00.000+05:30</published><updated>2013-08-05T08:04:50.829+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net Interview Questions"/><category scheme="http://www.blogger.com/atom/ns#" term="OopsConcepts"/><title type='text'>Boxing and UnBoxing in .Net Interview Question</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;One of the must and should question in&lt;b&gt; interviews&lt;/b&gt; is &lt;b&gt;What is Boxing and UnBoxing.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UnIntentionally while coding we will use this process many times. Let us explore this simple process.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
What is Boxing:&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;It is the &lt;b&gt;process of converting a value type into reference type&lt;/b&gt;. i..e Let us have a variable num which has value 100. It is a value type, now if we want to convert this to &lt;b&gt;reference type&lt;/b&gt; i.e &lt;b&gt;object type&lt;/b&gt; then this process is called as &lt;b&gt;Boxing.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int num=100;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; object&lt;/b&gt; obj=num;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
One thing we should remember here is &lt;b&gt;object &lt;/b&gt;is the &lt;b&gt;base type&lt;/b&gt; of all &lt;b&gt;data types in .net.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
What is UnBoxing:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It is exactly reverse of &lt;b&gt;Boxing,&lt;/b&gt; i.e &lt;b&gt;Converting a reference type&amp;nbsp; back to value type is called UnBoxing. &lt;/b&gt;But here&lt;b&gt; explicit type casting&lt;/b&gt; require.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int num=Convert.Int32(obj);&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_fblike_hcount&quot; displaytext=&quot;Facebook Like&quot;&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/4521195164581430527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/boxing-and-unboxing-in-net-interview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4521195164581430527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/4521195164581430527'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/boxing-and-unboxing-in-net-interview.html' title='Boxing and UnBoxing in .Net Interview Question'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-3617419508035806512</id><published>2013-07-13T20:43:00.006+05:30</published><updated>2015-01-18T10:05:35.463+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Dialog Controls"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows Forms"/><title type='text'>Dialog Controls in Windows Forms, How to use ColorDialog,FolderBrowserDialog,FontDialog,OpenFileDialog,SaveFileDialog example.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Dialog Controls in Windows Forms Application:&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction: &lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my previous articles&amp;nbsp; i explained various concepts on &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Asp.Net&quot; target=&quot;_blank&quot;&gt;Asp.Net&lt;/a&gt;,&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/WPF&quot; target=&quot;_blank&quot;&gt;WPF&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/OopsConcepts&quot; target=&quot;_blank&quot;&gt;Oops Concepts&lt;/a&gt; like &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/05/aspnet-validation-controls-tutorial.html&quot; target=&quot;_blank&quot;&gt;Asp.Net Validation Controls Tutorial&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/05/ajax-tutorial-aspnet-ajax-tutorial.html&quot; target=&quot;_blank&quot;&gt;Asp.Net Ajax Tutorial&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt;WPF Features&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;WPF Architecture&lt;/a&gt; etc.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Now we will see what are the different types of &lt;b&gt;DialogControls&lt;/b&gt; available in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Windows%20Forms&quot; target=&quot;_blank&quot;&gt;Windows Forms&lt;/a&gt; and &lt;b&gt;How to work with these Dialog Controls&lt;/b&gt; in Our Applications with an example.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp;Dialog Controls&lt;/b&gt; in &lt;b&gt;Window Forms&lt;/b&gt; help us to do some work quickly and easily and also provides us many options. In &lt;b&gt;Visual Studio&lt;/b&gt; toolbox there is separate Tab available for these &lt;b&gt;Dialog Controls in Windows Forms.&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-QJmHb0DYpd4/UeFjVhjAYTI/AAAAAAAAAUU/MBHFXuFbapM/s1600/Dialog+Controls+in+Windows+Forms.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-QJmHb0DYpd4/UeFjVhjAYTI/AAAAAAAAAUU/MBHFXuFbapM/s1600/Dialog+Controls+in+Windows+Forms.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
A &lt;b&gt;Dialog Control&lt;/b&gt; Even if added to a &lt;b&gt;form&lt;/b&gt; will not be displayed directly on the form. You will see them&lt;br /&gt;
in the bottom of the &lt;b&gt;studio&lt;/b&gt;. To make them visible in run-time on the &lt;b&gt;form&lt;/b&gt; we need to call a method &lt;br /&gt;
&lt;b&gt;ShowDialog().&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; A &lt;b&gt;Dialog Control&lt;/b&gt; will never perform any actions to use directly. We are only interfaces to perform the actions.They are responsible in displaying the available values to choose form to end users and returns back those values to &lt;b&gt;application developer.&lt;/b&gt; Now it is the responsibility of application developer to perform&lt;br /&gt;
the necessary actions with values chosen by end users.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;To capture the values that are chosen by end users application developers can make use of the following Properties.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Dialog Controls:&lt;/h4&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;ColorDialog &lt;/b&gt;-&amp;nbsp; Returns the Selected Color&lt;/li&gt;
&lt;li&gt;&lt;b&gt;FoloderBrowserDialog &lt;/b&gt;- Returns the Selected Folder Path.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;FontDialog &lt;/b&gt;- Returns the Selected Font.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OpenFileDialog &lt;/b&gt;- Returns the Filename&lt;/li&gt;
&lt;li&gt;&lt;b&gt;SaveFileDialog&lt;/b&gt; - Returns the Filename.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Dialog Controls usage with an example:&lt;/h4&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
Take a Form and add&lt;b&gt; ColorDialog,FontDialog,OpenFileDailog,SaveFileDialog,&lt;/b&gt; Four Buttons and a &lt;b&gt;PictureBox&lt;/b&gt; to form. Design them as shown in below.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-1QaiCRkWML4/UeFl49S4ogI/AAAAAAAAAUk/L1k-3acPk5Y/s1600/Dialog+Controls+Example.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-1QaiCRkWML4/UeFl49S4ogI/AAAAAAAAAUk/L1k-3acPk5Y/s1600/Dialog+Controls+Example.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Dailog Controls Example&lt;/td&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
2. Set the Text for four buttons as shown in above image i.e &lt;b&gt;Change Color, Change Font, Load Image,Save Image.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
3. Now in the Generate the Click event of Change Color Button write below Code.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;5&quot;&gt;            DialogResult dr = colorDialog1.ShowDialog();
            if(dr == DialogResult.OK)
                button1.BackColor = colorDialog1.Color;

&lt;/textarea&gt;



&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;This code will open the &lt;b&gt;ColorDialog Box, &lt;/b&gt;end user will chose the one color then when he press ok , then we are applying that color to &lt;b&gt;Button BackColor&lt;/b&gt;. If you Observe the code to open &lt;b&gt;ColorDialog Box &lt;/b&gt;we are calling &lt;b&gt;ShowDialog() &lt;/b&gt;method.&lt;br /&gt;
&lt;br /&gt;
4. Now generate the Click event of Change Font Button and write below code.&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;6&quot;&gt; DialogResult dr = fontDialog1.ShowDialog();
            if (dr == DialogResult.OK)
                button2.Font = fontDialog1.Font;

&lt;/textarea&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
Here also same in click event of Change Font Button we are opening &lt;b&gt;FontDialog &lt;/b&gt;Box, User will chose one Font and Press Ok then we are applying selected &lt;b&gt;Font&lt;/b&gt; to button &lt;b&gt;Font.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
5. Now generate the click event for Load Image Button and write below code.&lt;br /&gt;
&amp;nbsp;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;9&quot;&gt; openFileDialog1.Filter = &quot;Image Files (*.jpg)|*.jpg|Bitmap Images (*.bmp)|*.bmp|All File (*.*)|*.*&quot;;
            DialogResult dr = openFileDialog1.ShowDialog();
            if(dr != DialogResult.Cancel)
                pictureBox1.ImageLocation = openFileDialog1.FileName; 


&lt;/textarea&gt;

&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Here we are opening &lt;b&gt;OpenFileDailog&lt;/b&gt; Box by calling its &lt;b&gt;ShowDialog() &lt;/b&gt;method. If you observe the we are filtering the type of files it needs to show when open using &lt;b&gt;Filter&lt;/b&gt; &lt;b&gt;Property &lt;/b&gt;of &lt;b&gt;OpenFileDialog &lt;/b&gt;Control. In this button Click event user will Select an image then we are applying &lt;b&gt;Selected Filename&lt;/b&gt; to &lt;b&gt;Picturbox ImageLocation Property.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 6. Now generate click event for Save Button and Write below Code.&lt;br /&gt;
&lt;br /&gt;
&lt;textarea class=&quot;csharp&quot; cols=&quot;80&quot; name=&quot;code&quot; rows=&quot;10&quot;&gt; DialogResult d = MessageBox.Show(&quot;Are you sure you want save the image?&quot;, &quot;Image Save&quot;, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (d == DialogResult.Yes)
            {
                saveFileDialog1.Filter = &quot;Image Files (*.jpg)|*.jpg|Bitmap Images (*.bmp)|*.bmp|All File (*.*)|*.*&quot;;
                DialogResult dr = saveFileDialog1.ShowDialog();
                if (dr != DialogResult.Cancel)
                    pictureBox1.Image.Save(saveFileDialog1.FileName);
            }




&lt;/textarea&gt;


&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Here we are giving a prompt to user whether you want to save this image? If user press ok then we are opening &lt;b&gt;SaveFileDialog Box &lt;/b&gt;then User will save the file. That&#39;s it simple.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Whatever the &lt;b&gt;windows application&lt;/b&gt; whether it is &lt;b&gt;windows forms&lt;/b&gt; or &lt;b&gt;wpf application&lt;/b&gt;, these dialog controls and their functionality is common. But in &lt;b&gt;WPF applications&lt;/b&gt; we can&#39;t find these controls available in &lt;b&gt;toolbox.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To add these controls in &lt;b&gt;WPF&lt;/b&gt; we have to add &lt;b&gt;namespace System.Windows.Control&lt;/b&gt; reference to &lt;b&gt;project &lt;/b&gt;and &lt;b&gt;Import&lt;/b&gt; the &lt;b&gt;namespace&lt;/b&gt; in Corresponding &lt;b&gt;Window&lt;/b&gt; or &lt;b&gt;Page.&lt;/b&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Important Points Regarding Dialog Controls:&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;To open a &lt;b&gt;DialogControl&lt;/b&gt; we have to Call &lt;b&gt;ShowDialog() &lt;/b&gt;method.&lt;/li&gt;
&lt;li&gt;Every &lt;b&gt;DialogBox &lt;/b&gt;will return a value of type &lt;b&gt;DialogResult&lt;/b&gt;, based on this value we have to go further action.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;For &lt;b&gt;OpenFileDialog&lt;/b&gt; Box and &lt;b&gt;SaveFileDialog &lt;/b&gt;Boxes &lt;b&gt;Filter Property&lt;/b&gt; available to &lt;b&gt;Filter&lt;/b&gt; type of documents to show.&lt;/li&gt;
&lt;/ul&gt;
Apart from this &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa984180%28v=vs.71%29.aspx&quot; target=&quot;_blank&quot;&gt;PrintPreviewDialog&lt;/a&gt; box available to show preview of your document when it available for printing. You can find other controls of Windows Forms &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/aa984070%28v=vs.71%29.aspx&quot; target=&quot;_blank&quot;&gt;Here&lt;/a&gt;.&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In this way we can work with or use Dialog Controls in Windows Foms.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Don&#39;t forget to Comment and share for our friends if you like this post.&lt;/h4&gt;
&lt;/div&gt;&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/3617419508035806512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/dialog-controls-in-windows-forms-how-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3617419508035806512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/3617419508035806512'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/dialog-controls-in-windows-forms-how-to.html' title='Dialog Controls in Windows Forms, How to use ColorDialog,FolderBrowserDialog,FontDialog,OpenFileDialog,SaveFileDialog example.'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-QJmHb0DYpd4/UeFjVhjAYTI/AAAAAAAAAUU/MBHFXuFbapM/s72-c/Dialog+Controls+in+Windows+Forms.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1858172642880296245.post-2424678110399819959</id><published>2013-07-13T08:07:00.000+05:30</published><updated>2015-01-18T10:05:57.691+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows Forms"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>WPF vs Windows Forms what is the difference between windows forms and wpf in properties, methods,events of the control</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
WPF Vs Windows Forms&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Introduction:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
In my previous articles i explained&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt; what is wpf and wpf features&lt;/a&gt;, &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;Architecture of WPF&lt;/a&gt; and&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/04/basic-drawings-and-shapes-in-WPF-using-xaml-tags.html&quot; target=&quot;_blank&quot;&gt; Basic shapes and drawings in WPF&lt;/a&gt; and Various articles on&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/Asp.Net&quot; target=&quot;_blank&quot;&gt; Asp.Net&lt;/a&gt; and &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/search/label/OopsConcepts&quot; target=&quot;_blank&quot;&gt;OopsConcepts.&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Now i will explain differences between &lt;b&gt;WPF&lt;/b&gt; and &lt;b&gt;Windows Forms&lt;/b&gt; in-terms of their &lt;b&gt;properties, events and methods.&lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Description:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
WPF vs Windows Forms:&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://2.bp.blogspot.com/-AEpunawWQ1Y/UeC-Dk_s-bI/AAAAAAAAAUE/Q7sVoVjm_4o/s1600/WPF+Vs+Windows+Forms.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-AEpunawWQ1Y/UeC-Dk_s-bI/AAAAAAAAAUE/Q7sVoVjm_4o/s1600/WPF+Vs+Windows+Forms.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As earlier i explained in &lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt;WPF features&lt;/a&gt;, We can say all that features are &lt;b&gt;advantages of wpf over windows forms.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now see the differences in simple terms:&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
WPF:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Pros:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Powerfull &lt;b&gt;styling&lt;/b&gt; and &lt;b&gt;skinning structure&lt;/b&gt; is possible.&lt;/li&gt;
&lt;li&gt;Easy to create an own look and feel.&lt;/li&gt;
&lt;li&gt;Does support windows forms.&lt;/li&gt;
&lt;li&gt;Future technology for developing vista applications.&lt;/li&gt;
&lt;li&gt;we can reuse the code.&lt;/li&gt;
&lt;li&gt;Highly &lt;b&gt;data binding&lt;/b&gt; is possible.&lt;/li&gt;
&lt;li&gt;Almost all features of &lt;b&gt;HTML and Flash&lt;/b&gt; are available.&lt;/li&gt;
&lt;li&gt;Support fixed and flow format documents. &lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Cons:&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Declarative Vs Procedural Code.&lt;/li&gt;
&lt;li&gt;Required .Net Framework.&lt;/li&gt;
&lt;li&gt;Still in development Phase.&lt;/li&gt;
&lt;li&gt;Required Advanced Graphics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Windows Forms:&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Pros:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Extensive documentation found on the internet.&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Plenty of examples.&lt;/li&gt;
&lt;li&gt;Does support WPF.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Cons:&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;How long will it be supported( As i read in other sites microsoft stops further developing windows forms from 2.0, It is focusing on&amp;nbsp; WPF).&lt;/li&gt;
&lt;li&gt;It requires lot of time and work to have good design.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Differences between Windows Forms and WPF in Properties,Methods,and Events for Control:&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In Windows Forms Controls like &lt;b&gt;Button&lt;/b&gt;, &lt;b&gt;RadioButton&lt;/b&gt;, &lt;b&gt;Label&lt;/b&gt;, &lt;b&gt;CheckBox&lt;/b&gt; and &lt;b&gt;TextBox&lt;/b&gt; have Text Property to provide a caption for them but these controls have&lt;b&gt; &#39;Content&#39; Property in WPF&lt;/b&gt;. &lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;&amp;nbsp;In &lt;b&gt;Windows Forms&lt;/b&gt; to provide &lt;b&gt;access key&lt;/b&gt; for a control with in that text of the control, the character to use as &lt;b&gt;access key&lt;/b&gt; will be pr&lt;b&gt;efixed with &amp;amp; symbol&lt;/b&gt; but in &lt;b&gt;WPF&lt;/b&gt; the character to provide as access key have to be &lt;b&gt;prefixed(_) underscore&lt;/b&gt; with in the&lt;b&gt; content property&lt;/b&gt;.&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;&amp;nbsp;In &lt;b&gt;Windows Forms&lt;/b&gt; to use the &lt;b&gt;TextBox&lt;/b&gt; for accepting the &lt;b&gt;password&lt;/b&gt; you have to set &lt;b&gt;password char property&lt;/b&gt; for it but in wpf there is no property for &lt;b&gt;textbox&lt;/b&gt; and instead you have a separate control available for accepting the password that is &lt;b&gt;PasswordBox&lt;/b&gt;.&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;In &lt;b&gt;Windows Forms&lt;/b&gt; applications controls have the &lt;b&gt;Property&lt;/b&gt; Font to specify the &lt;b&gt;Font&lt;/b&gt;, &lt;b&gt;Font-Size&lt;/b&gt;, &lt;b&gt;Font-Style&lt;/b&gt; but in &lt;b&gt;WPF&lt;/b&gt; the&lt;b&gt; Font&lt;/b&gt; property is splitted into multiple properties&lt;b&gt; Font-Size&lt;/b&gt;, &lt;b&gt;Font-Family&lt;/b&gt;,&lt;b&gt;Font - Stretch&lt;/b&gt;, &lt;b&gt;Font Style&lt;/b&gt; and&lt;b&gt; Font Weight&lt;/b&gt;.&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;In &lt;b&gt;windows forms&lt;/b&gt; &lt;b&gt;background color and foreground color propertie&lt;/b&gt;s are used to specify the background color and foreground color. But in &lt;b&gt;WPF&lt;/b&gt; this properties are renamed as &lt;b&gt;Background&lt;/b&gt; and &lt;b&gt;Foreground&lt;/b&gt; which can be used to change the B&lt;b&gt;ackground and Foreground colors&lt;/b&gt; and also &lt;b&gt;Background and Foreground Images.&lt;/b&gt;&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;Most of the &lt;b&gt;Boolean properties&lt;/b&gt; in &lt;b&gt;WPF&lt;/b&gt; are &lt;b&gt;prefixed&lt;/b&gt; with Is. The property for &lt;b&gt;CheckBox&lt;/b&gt; and &lt;b&gt;RadioButton&lt;/b&gt; to determine whether or not it is checked &lt;b&gt;&#39;IsChecked&#39;.&lt;/b&gt;&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt;For the &lt;b&gt;CheckBox&lt;/b&gt; and &lt;b&gt;RadioButton&lt;/b&gt; the &lt;b&gt;default event in Windows Forms is checked-changed&lt;/b&gt;, but in &lt;b&gt;WPF checked changed event is not available&lt;/b&gt; for &lt;b&gt;CheckBox&lt;/b&gt; and &lt;b&gt;RadioButton&lt;/b&gt; and Instead of they have two events &lt;b&gt;Checked&lt;/b&gt; and &lt;b&gt;UnChecked&lt;/b&gt;, that will be raised whenever the &lt;b&gt;RadioButton&lt;/b&gt; and &lt;b&gt;CheckBox&lt;/b&gt; is checked and &lt;b&gt;Unchecked&lt;/b&gt;.&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt; In &lt;b&gt;Windows Forms&lt;/b&gt; there are &lt;b&gt;three keyboard events key-down&lt;/b&gt;, &lt;b&gt;key-up&lt;/b&gt; and &lt;b&gt;key-press&lt;/b&gt; but in &lt;b&gt;WPF&lt;/b&gt; there are only two keyboard events i.e&lt;b&gt; key Down&lt;/b&gt; and &lt;b&gt;Key Up&lt;/b&gt; and&lt;b&gt; Key press&lt;/b&gt; is not available in &lt;b&gt;WPF&lt;/b&gt;.&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt; In &lt;b&gt;Window Forms&lt;/b&gt; whenever focus enter into control , &lt;b&gt;Enter event&lt;/b&gt; will be raised and whenever &lt;b&gt;focus leaves&lt;/b&gt; the control&lt;b&gt; leave&lt;/b&gt; event will be raised. but these events were renamed in &lt;b&gt;WPF&lt;/b&gt; as &lt;b&gt;gotfocus&lt;/b&gt; and &lt;b&gt;lostfocus.&lt;/b&gt;&lt;/li&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;li&gt; &lt;b&gt;WPF&lt;/b&gt; provides a control called &lt;b&gt;TextBlock&lt;/b&gt; that is similar to a &lt;b&gt;label&lt;/b&gt;, which will not allow to &lt;br /&gt;the text, but all the properties of the &lt;b&gt;TextBlock&lt;/b&gt; are similar to a &lt;b&gt;TextBox&lt;/b&gt; and not the &lt;b&gt;label&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Conclusion:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
These are all the &lt;b&gt;differences&lt;/b&gt; in - terms&amp;nbsp; &lt;b&gt;features and properties,methods and events between WPF and Windows Forms&lt;/b&gt;.In my next article i will explain &lt;b&gt;What are the layout controls available in WPF&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;b&gt; Don&#39;t forget to comment and share it for our friends if you like this post.Thank You.&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;display:inline; padding-bottom:5px;&quot; class=&quot;fb-like&quot; data-href=&quot;https://www.facebook.com/aspdotnetsekhar&quot; data-width=&quot;30px&quot; data-layout=&quot;standard&quot; data-action=&quot;like&quot; data-show-faces=&quot;true&quot; data-share=&quot;false&quot;&gt;&lt;/div&gt;
&lt;span class=&quot;st_sharethis_hcount&quot; displaytext=&quot;ShareThis&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_googleplus_hcount&quot; displaytext=&quot;Google +&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_facebook_hcount&quot; displaytext=&quot;Facebook&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_twitter_hcount&quot; displaytext=&quot;Tweet&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;st_linkedin_hcount&quot; displaytext=&quot;LinkedIn&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Related Posts:&lt;/h4&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/07/What-is-wpf-introduction-to-windows-presentation-foundation--wpf-features-tutorial.html&quot; target=&quot;_blank&quot;&gt;W&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/null&quot; target=&quot;_blank&quot;&gt;hat is WPF and Features of WPF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/03/wpf-architecture-overviewwindows.html&quot; target=&quot;_blank&quot;&gt;Architecture of WPF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://aspdotnet-sekhar.blogspot.in/2013/04/basic-drawings-and-shapes-in-WPF-using-xaml-tags.html&quot; target=&quot;_blank&quot;&gt;How to draw basic shapes and drawings in WPF. &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;br /&gt;
&lt;/ul&gt;
&lt;script&gt;
  (function(i,s,o,g,r,a,m){i[&#39;GoogleAnalyticsObject&#39;]=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,&#39;script&#39;,&#39;//www.google-analytics.com/analytics.js&#39;,&#39;ga&#39;);

  ga(&#39;create&#39;, &#39;UA-42380788-1&#39;, &#39;aspdotnet-sekhar.blogspot.in&#39;);
  ga(&#39;send&#39;, &#39;pageview&#39;);

&lt;/script&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.aspdotnet-sekhar.com/feeds/2424678110399819959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/WPF-vs-Windows-Forms-difference-between-wpf-windows-forms-in-events-properites-methods-for-control.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2424678110399819959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1858172642880296245/posts/default/2424678110399819959'/><link rel='alternate' type='text/html' href='http://www.aspdotnet-sekhar.com/2013/07/WPF-vs-Windows-Forms-difference-between-wpf-windows-forms-in-events-properites-methods-for-control.html' title='WPF vs Windows Forms what is the difference between windows forms and wpf in properties, methods,events of the control'/><author><name>Sekhar Babu</name><uri>http://www.blogger.com/profile/07996412439198639920</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidH0ee0vi8MAGw2z0tYMTSqjdVtz-mmD8KGL4hsDBxBg-3EPHfi8CJCiGgB5Q3Uezx8UTLaUpH4XGh4bG3MYqpAzVYGlPJSlX31Dx9zowrLCj0pY_PtYnqAoxAgMhfSw/s1600/DN4yOjpu_400x400.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-AEpunawWQ1Y/UeC-Dk_s-bI/AAAAAAAAAUE/Q7sVoVjm_4o/s72-c/WPF+Vs+Windows+Forms.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>