<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Konczuras&#039;s Blog</title>
	<atom:link href="http://konczuras.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://konczuras.wordpress.com</link>
	<description>Dedicated to development</description>
	<lastBuildDate>Mon, 16 Jan 2012 13:52:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='konczuras.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Konczuras&#039;s Blog</title>
		<link>http://konczuras.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://konczuras.wordpress.com/osd.xml" title="Konczuras&#039;s Blog" />
	<atom:link rel='hub' href='http://konczuras.wordpress.com/?pushpress=hub'/>
		<item>
		<title>REST in ASP.NET MVC – Generating XML</title>
		<link>http://konczuras.wordpress.com/2012/01/14/rest-in-asp-net-mvc-generating-xml/</link>
		<comments>http://konczuras.wordpress.com/2012/01/14/rest-in-asp-net-mvc-generating-xml/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 20:00:16 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[POX]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=755</guid>
		<description><![CDATA[Nowadays I have a hobby project – a beer catalog for mobile devices. It sounds pretty simple, but I managed to make it complex – and robust as well. The solution has three parts: an ASP.NET MVC web site backed up by SQL Server, an iPhone and an Android client. I struggled a lot with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=755&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Nowadays I have a hobby project – a beer catalog for mobile devices. It sounds pretty simple, but I managed to make it complex – and robust as well.<br />
The solution has three parts: an ASP.NET MVC web site backed up by SQL Server, an iPhone and an Android client. I struggled a lot with WCF, I thought it would be the right way to implement a REST-based service, but couldn’t figure it out myself. Anyway, I had an MVC site up and running, so I thought I can sort this out pretty easy, since I had an object model with five entities – that means five services to the mobile apps.<br />
I’ll write about the mobile clients in a future post. It’s enough to know that they pull the data from the services and store it in their own SQLite 3 databases. Sometimes (maybe once a week) they perform an update, request the data again and overwrite their existing databases – that’s all that there’s relevant now.<br />
So how would you create a REST API in ASP.NET MVC. I felt that I want something terribly simple. I want to say that return this data as XML, without any duplication. The obvious way was to subclass ActionResult. After some inspiration from <a href="http://www.wduffy.co.uk/blog/rssresult-aspnet-mvc-rss-actionresult/">William Duffy’s RSSResult implementation</a>, I came up with the following code:</p>
<blockquote>
<ol>
<ol>
<li><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> XMLResult&lt;T&gt; : ActionResult</li>
<li>  {</li>
<li>    <span style="color:#0000ff;">private</span> <span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; _items;</li>
<li>    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> _rootName;</li>
<li>    <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> _typeName;</li>
<li></li>
<li>    <span style="color:#0000ff;">public</span> XMLResult(<span style="color:#2b91af;">IEnumerable</span>&lt;T&gt; items, <span style="color:#0000ff;">string</span> rootName, <span style="color:#0000ff;">string</span> typeName)</li>
<li>    {</li>
<li>      _items = items;</li>
<li>      _rootName = rootName;</li>
<li>      _typeName = typeName;</li>
<li>    }</li>
<li>    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">override</span> <span style="color:#0000ff;">void</span> ExecuteResult(ControllerContext context)</li>
<li>    {</li>
<li>      <span style="color:#0000ff;">if</span> (_items == <span style="color:#0000ff;">null</span>)</li>
<li>      {</li>
<li>        <span style="color:#0000ff;">throw</span> <span style="color:#0000ff;">new</span> NullReferenceException();</li>
<li>      }</li>
<li>      XmlWriterSettings settings = <span style="color:#0000ff;">new</span> XmlWriterSettings() { Indent = <span style="color:#0000ff;">true</span>, NewLineHandling = NewLineHandling.Entitize };</li>
<li>      context.<span style="color:#2b91af;">HttpContext</span>.Response.ContentType = <span style="color:#a31515;">&#8220;text/xml&#8221;</span>;</li>
<li></li>
<li>      <span style="color:#0000ff;">using</span> (XmlWriter writer = XmlWriter.Create(context.<span style="color:#2b91af;">HttpContext</span>.Response.OutputStream, settings))</li>
<li>      {</li>
<li></li>
<li>        writer.WriteStartElement(_rootName);</li>
<li>        <span style="color:#0000ff;">foreach</span> (T item <span style="color:#0000ff;">in</span> _items)</li>
<li>        {</li>
<li>          <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">string</span>.IsNullOrEmpty(_typeName))</li>
<li>          {</li>
<li>            writer.WriteStartElement(item.GetType().Name);</li>
<li>          }</li>
<li>          <span style="color:#0000ff;">else</span></li>
<li>          {</li>
<li>            writer.WriteStartElement(_typeName);</li>
<li>          }</li>
<li>          <span style="color:#0000ff;">foreach</span> (PropertyInfo pi <span style="color:#0000ff;">in</span> item.GetType().GetProperties())</li>
<li>          {</li>
<li>            <span style="color:#0000ff;">if</span> (pi.PropertyType.IsValueType || pi.PropertyType == <span style="color:#0000ff;">typeof</span>(<span style="color:#0000ff;">string</span>))</li>
<li>            {</li>
<li>              <span style="color:#0000ff;">if</span> (pi.GetValue(item, <span style="color:#0000ff;">null</span>) != <span style="color:#0000ff;">null</span>)</li>
<li>              {</li>
<li>                writer.WriteElementString(pi.Name, pi.GetValue(item, <span style="color:#0000ff;">null</span>).ToString());</li>
<li>              }</li>
<li>            }</li>
<li>          }</li>
<li>          writer.WriteEndElement();</li>
<li>        }</li>
<li>        writer.WriteEndElement();</li>
<li>      }</li>
<li></li>
<li>    }</li>
<li>  }</li>
</ol>
</ol>
<p><span style="color:gray;font-size:xx-small;">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><span style="color:gray;font-size:xx-small;">Source Code Highlighter</span></a>.</span></p></blockquote>
<p>I think it speaks for itself. The only thing needs a little explanation is the narrowing of the types in the PropertyInfo loop. I needed only value types and string, nothing else. Since my entities contained BLOB data and navigation properties, I got rid of the rest.<br />
This little class is used as follows:</p>
<blockquote>
<ol>
<ol>
<li><span style="color:#0000ff;">public</span> XMLResult&lt;Beer&gt; Beers()</li>
<li>    {</li>
<li>      <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">new</span> XMLResult&lt;Beer&gt;(context.Beers.Where(x=&gt;x.IsApproved.Value).OrderBy(x=&gt;x.Name), <span style="color:#a31515;">&#8220;Beers&#8221;</span>, <span style="color:#a31515;">&#8220;Beer&#8221;</span>);</li>
<li>    }</li>
</ol>
</ol>
<p><span style="color:gray;font-size:xx-small;">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><span style="color:gray;font-size:xx-small;">Source Code Highlighter</span></a>.</span></p></blockquote>
<p>And it works with basically anything, thanks to the generic type parameter. From this startpoint, you can easily implement your own POX (Plain Old XML) services with ASP.NET MVC. In the next post we consider how to extract the entities from the generated XML on the iPhone.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/755/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/755/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/755/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/755/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/755/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/755/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/755/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/755/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=755&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2012/01/14/rest-in-asp-net-mvc-generating-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Double-click in Silverlight</title>
		<link>http://konczuras.wordpress.com/2011/10/14/double-click-in-silverlight/</link>
		<comments>http://konczuras.wordpress.com/2011/10/14/double-click-in-silverlight/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 11:04:10 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=751</guid>
		<description><![CDATA[It’s a bit nonsense for me, but in Silverlight, there’s no double click event. A little annoying issue, but fortunately, we can craft our own double click with the help of the MouseLeftButtonUp event and a timer (I’ll show the bare minimum here, let’s call it the poor man’s double click). First you need a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=751&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:small;"><span style="font-family:Calibri;">It’s a bit nonsense for me, but in Silverlight, there’s no double click event. A little annoying issue, but fortunately, we can craft our own double click with the help of the MouseLeftButtonUp event and a timer (I’ll show the bare minimum here, let’s call it the poor man’s double click).</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">First you need a timer. To avoid some nasty threading issues, we use the DispatcherTimer – it runs on the same thread as the Dispatcher. I created it as a private field of my UserControl, so I assume you did this too.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">I also created an event for the double click, but it’s fairly convenient. The main interest is the MouseLeftButtonUp event, which looks like this:</span></span></p>
<blockquote><p><code><font size="2" face="Courier New" color="black"><font color="#0000ff">private</font> <font color="#0000ff">void</font> Control_MouseLeftButtonUp(<font color="#0000ff">object</font> sender, MouseButtonEventArgs e)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">if</font> (_doubleClickTimer.IsEnabled)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_doubleClickTimer.Stop();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">if</font> (<font color="#0000ff">this</font>.DoubleClick != <font color="#0000ff">null</font>)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">this</font>.DoubleClick(<font color="#0000ff">this</font>, <font color="#0000ff">null</font>);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">else</font><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_doubleClickTimer.Interval = <font color="#0000ff">new</font> <font color="#2B91AF">TimeSpan</font>(0, 0, 0, 0, 400);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_doubleClickTimer.Tick += (o, e2) =&#062; _doubleClickTimer.Stop();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_doubleClickTimer.Start();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</font></p>
<p><font size="1" color="gray">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><font size="1" color="gray">Source Code Highlighter</font></a>.</font></code></p></blockquote>
<p><span style="font-size:small;"><span style="font-family:Calibri;">The source code is pretty simple. First we check if our DispatcherTimer has an enabled state. If it does, it means that it’s already started. If it’s started, then it means that the user must have clicked once on the control. That’s because if the DispatcherTimer isn’t started, then the else branch will run, which does nothing more than start a timer with a reasonable 400 milliseconds double-click experience, sets that it should run only once, then starts it.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">So if our timer was started that means we are no longer than 400 milliseconds after the first click, so we have a double click! And we fire the double click event. That’s all, use it, extend it as you wish. </span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/751/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/751/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/751/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/751/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/751/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/751/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/751/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/751/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=751&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/10/14/double-click-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Auto update an OOB Silverlight application</title>
		<link>http://konczuras.wordpress.com/2011/10/10/auto-update-an-oob-silverlight-application/</link>
		<comments>http://konczuras.wordpress.com/2011/10/10/auto-update-an-oob-silverlight-application/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 08:15:28 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Auto update]]></category>
		<category><![CDATA[OOB]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=748</guid>
		<description><![CDATA[So you created an application, have a shortcut to it on your desktop, but whenever you change it, you have to delete the link and create a new one? This problem can be solved easily. The following code snippet does it for you: if (Current.IsRunningOutOfBrowser)       {         Current.CheckAndDownloadUpdateCompleted += (s, e2) =&#62;         {           if (e2.UpdateAvailable)           { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=748&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:small;"><span style="font-family:Calibri;">So you created an application, have a shortcut to it on your desktop, but whenever you change it, you have to delete the link and create a new one?</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">This problem can be solved easily. The following code snippet does it for you:</span></span></p>
<blockquote>
<ol>
<ol>
<li><span style="color:#0000ff;">if</span> (Current.IsRunningOutOfBrowser)</li>
<li>      {</li>
<li>        Current.CheckAndDownloadUpdateCompleted += (s, e2) =&gt;</li>
<li>        {</li>
<li>          <span style="color:#0000ff;">if</span> (e2.UpdateAvailable)</li>
<li>          {</li>
<li>            MessageBox.Show(<span style="color:#a31515;">&#8220;A new version was found, please restart the Application!&#8221;</span>);</li>
<li></li>
<li>            <span style="color:#0000ff;">if</span> (e2.Error != <span style="color:#0000ff;">null</span>)</li>
<li>            {</li>
<li>              MessageBox.Show(<span style="color:#a31515;">&#8220;There was an error updating the application!&#8221;</span>);</li>
<li>            }</li>
<li>          }</li>
<li></li>
<li>        };</li>
<li>        Current.CheckAndDownloadUpdateAsync();</li>
<li>      }</li>
</ol>
</ol>
<p>&nbsp;</p>
<p><span style="color:gray;font-size:xx-small;">* This source code was highlighted with <a href="http://virtser.net/blog/post/source-code-highlighter.aspx"><span style="color:gray;font-size:xx-small;">Source Code Highlighter</span></a>.</span></p></blockquote>
<p><span style="font-size:small;"><span style="font-family:Calibri;">However, there are some quirks. You shouldn’t check the “Require elevated trust when running outside the browser”, because if you do so, auto update fails to start.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">And another one: if you place the code above in the app constructor, it won’t work. The earliest stage I manage to get it work was the Application_Startup method.</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/748/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/748/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/748/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=748&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/10/10/auto-update-an-oob-silverlight-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Full screen Silverlight</title>
		<link>http://konczuras.wordpress.com/2011/10/09/full-screen-silverlight/</link>
		<comments>http://konczuras.wordpress.com/2011/10/09/full-screen-silverlight/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 14:23:56 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Workaround]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=744</guid>
		<description><![CDATA[So you’d like your app to run full screen, don’t you? Are you ready to get your brain blown off? Then let’s get started with it. First rule: you can only enter full screen as a result of a user initiated action. This is a security feature, and I don’t know the reason of it, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=744&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:small;"><span style="font-family:Calibri;">So you’d like your app to run full screen, don’t you? Are you ready to get your brain blown off? Then let’s get started with it.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">First rule: you can only enter full screen as a result of a user initiated action. This is a security feature, and I don’t know the reason of it, but smarter guys will tell you if you ask them. So no full screen enters in Window_Loaded event handlers, but you can add a MouseLeftButtonUp handler to the same window, and add the following code to the event handler:</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">Application.Current.Host.Content.IsFullScreen = true;</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">Security bypassed, the user initiated the action (although totally unaware of it). You might think that you’re good to go from now on, your application running full screen, everybody is happy. Sadly, there’s a little quirk here: you won’t get full keyboard support running full screen.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">I was a little unspecific about what is full keyboard support. Well, you can rest assured that you can’t type in anything, but you can move around with arrows. Nice, isn’t it? Before you ask, no there’s no way to code this around.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">From version 4, we have a solution to your problem. Setting the Application.Current.MainWindow.WindowState property to Maximized, you can have a maximized window on startup. You don’t even need the user to initiate an action for you, it just works. The code for the lazy ones:</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">Application.Current.MainWindow.WindowState = WindowState.Maximized;</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">It’s not full screen, just a plain old maximized window, but it did the trick for me.</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/744/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/744/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/744/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=744&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/10/09/full-screen-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>The state of the Silverlight platform</title>
		<link>http://konczuras.wordpress.com/2011/10/09/the-state-of-the-silverlight-platform/</link>
		<comments>http://konczuras.wordpress.com/2011/10/09/the-state-of-the-silverlight-platform/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 14:08:25 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=741</guid>
		<description><![CDATA[I remember starting this blog one and a half year ago with a furious post on the immaturity of Silverlight (back then I think the version was 2.0). Now I’m working on the biggest project so far in my career, and guess what the platform is? Yes, of course, Silverlight. So we’re arriving to version [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=741&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:small;"><span style="font-family:Calibri;">I remember starting this blog one and a half year ago with a furious post on the immaturity of Silverlight (back then I think the version was 2.0). Now I’m working on the biggest project so far in my career, and guess what the platform is? Yes, of course, Silverlight.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">So we’re arriving to version 5.0 in a matter of days, and we’re also having (or at least I’m having) nightmares about the future. After watching the BUILD conference, scanning through the news, blogs, forums, whatever I had the feeling that Silverlight won’t last that long. (Of course, Silverlight is a first-class citizen of the new Windows 8 platform, but we didn’t even mention it in the keynote). After the first suspicious thoughts came the campaign of Silverlight’s importance, which further strengthened my feelings that something is wrong here. But enough of this.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;"><span id="more-741"></span></span></span></p>
<p><span style="font-family:Calibri;"><span style="font-size:small;">I came to the decision that there’s no point arguing about wasted development efforts (I learn something new every day – and not about Silverlight, but about <em>Software development in general</em>) and the rest. No effort wasted as long as you think. The only one has to worry about this is my boss, who took the decision of rewriting the company’s flagship product in Silverlight. But he has his points, so let’s take a look around.</span></span></p>
<p><span style="font-family:Calibri;"><span style="font-size:small;">You want to take your business application to the browser <em>and </em>you want to provide rich user experience – generally, you want a rich internet application. What do you chose? I’ve fiddled enough with Javascript frameworks like ExtJs, and they are simply not enough (for me, the .NET guy). Also, you can start writing something in HTML5, but that’s not a lot better, in my opinion. Add existing .NET developers to the scene, along with a strong Microsoft partnership: it leads to Silverlight.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">As I said, I’m writing my biggest application (healthcare system) and I feel that Silverlight is not the best tool for the job – I stumble into some immaturity, inconsistent function, etc. daily, not to mention the horror of adding yet another toolkit. I pretty much enjoyed subclassing existing controls (an effect of Cocoa development), but you get fed up with that too, just to make a dumb Combobox work.</span></span></p>
<p><span style="font-family:Calibri;"><span style="font-size:small;">Anyway, Silverlight is bad, but it’s not that bad. My troubles stem from the fact that I worked with WPF <em>before </em>I take a chance with Silverlight, and from the fact that I know what I’m missing. And because of this, I plan to publish some painfully earned gems on this blog, like how you can make a full screen app that you can type into, or how to make a crappy data binding to a Combobox. Just to help you guys out there googling the same crap I do daily.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">Happy coding!</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/741/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/741/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/741/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=741&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/10/09/the-state-of-the-silverlight-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Certified: 70-506 Silverlight 4 Development</title>
		<link>http://konczuras.wordpress.com/2011/09/03/getting-certified-70-506-silverlight-4-development/</link>
		<comments>http://konczuras.wordpress.com/2011/09/03/getting-certified-70-506-silverlight-4-development/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 06:58:02 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=736</guid>
		<description><![CDATA[It’s been quite a long time since I took the time to get another Microsoft certification, but this business makes you addict. You show no symptoms for a while, but then it strikes you when you least except it. Why Silverlight? The answer is simple: I hold no Silverlight certification – and moreover I’m working [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=736&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It’s been quite a long time since I took the time to get another Microsoft certification, but this business makes you addict. You show no symptoms for a while, but then it strikes you when you least except it.</p>
<p>Why Silverlight? The answer is simple: I hold no Silverlight certification – and moreover I’m working on a big project which is based on Silverlight and it strikes me every day  ow much I don’t know about it.</p>
<p>So from now on, except some Silverlight posts based on Microsoft Learning’s <a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-506&amp;locale=en-us#tab2">skills being measured section</a>.</p>
<p>Hopefully I’ll have the time to write some posts about my first (successful) iOs application, it became the number one in Hungary for a week or so.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/736/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/736/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/736/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/736/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/736/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/736/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/736/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/736/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=736&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/09/03/getting-certified-70-506-silverlight-4-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Life signal</title>
		<link>http://konczuras.wordpress.com/2011/04/26/life-signal/</link>
		<comments>http://konczuras.wordpress.com/2011/04/26/life-signal/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 16:40:14 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=732</guid>
		<description><![CDATA[Quite a lot of time passed since my last blog post, so this one will be more of a dull what’s with me note. You won’t find any useful information regarding your work/learning/etc. I’m currently building an iPhone/iPad app which is connected to PHP sites running MySql in the background and result in content users [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=732&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-size:small;"><span style="font-family:Calibri;">Quite a lot of time passed since my last blog post, so this one will be more of a dull what’s with me note. You won’t find any useful information regarding your work/learning/etc.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">I’m currently building an iPhone/iPad app which is connected to PHP sites running MySql in the background and result in content users reading printed magazines on their devices, thus saving quite a lot of trees (and me getting bald). This app is so economical that there are two in one, further reducing the carbon footprint (In fact, reducing it better than Microsoft with not sending certifications out, only if you pay for it.). But enough of this, you want code, not complaints.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">And code is what you’ll get. I’ve made some patches to the LeavesView project on GitHub, so that now you zoom into it without nice system crashes. I’ll create a fork on the project after the thing is tested and proved well.</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">The MS certification track is suspended now, because I think I have had enough for now. I collected ten certs in a year, and I don’t feel like I need another ten. Also, I’m a little bit upset, because MS certification prices will be raised (OK, I can live with it), but you can’t find out the rate, because the cert price calculator is just plain wrong (maybe a Silverlight MCTS would be able to help).</span></span></p>
<p><span style="font-size:small;"><span style="font-family:Calibri;">I’ll post soon, because I read a lot about data structures, algorithms, coding practices and I’m eager to create a book list. Until then, happy coding to everyone, and check out my iPhone app when it gets into the store. I’ll make a post for it, too.</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/732/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/732/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/732/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/732/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/732/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/732/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/732/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/732/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=732&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/04/26/life-signal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>70-511 Passed</title>
		<link>http://konczuras.wordpress.com/2011/02/26/70-511-passed/</link>
		<comments>http://konczuras.wordpress.com/2011/02/26/70-511-passed/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 07:26:50 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF 70-511]]></category>
		<category><![CDATA[70-511]]></category>
		<category><![CDATA[Exam]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=729</guid>
		<description><![CDATA[Yesterday I passed the exam MCTS Windows Applications Development with Microsoft .NET Framework 4 which completes my seventh MCTS – although the first in Windows client development. I did an MCTS exam a while ago, and I was a bit shocked how easy it was – I “overprepared” myself.. I thought that you can pass [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=729&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I passed the exam MCTS Windows Applications Development with Microsoft .NET Framework 4 which completes my seventh MCTS – although the first in Windows client development.</p>
<p>I did an MCTS exam a while ago, and I was a bit shocked how easy it was – I “overprepared” myself.. I thought that you can pass this one with a deep understanding of the .NET Framework and a little WPF knowledge – but this way, you’d need to use your common sense.</p>
<p>There were some questions on WPF and Windows Forms integration, but you could figure them out with a little thinking. Also there were some on UI aligning, UAC, ClickOnce abd parallelism. The questions were that MCTS type, so they focused on <em>how</em> to do something instead of <em>why</em>, but that was expected.</p>
<p>My next goal is the .NET 4 Windows MCPD exam – which is filled with cool architectural decisions, as I looked briefly on the skills measured section.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/729/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=729&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/02/26/70-511-passed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Implement dependency properties</title>
		<link>http://konczuras.wordpress.com/2011/02/20/implement-dependency-properties/</link>
		<comments>http://konczuras.wordpress.com/2011/02/20/implement-dependency-properties/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 12:02:19 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Enhancing the Functionality and Usability of a Solution]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF 70-511]]></category>
		<category><![CDATA[Dependency Property]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=727</guid>
		<description><![CDATA[May include but is not limited to: enabling data binding and animation, property metadata, property change callbacks WPF adds a new concept to the classic .NET property world, namely dependency properties. They introduce some nice new features such as property value inheritance and change notification. You can imagine that most of the WPF properties are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=727&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>May include but is not limited to: enabling data binding and animation, property metadata, property change callbacks</em></p>
<p>WPF adds a new concept to the classic .NET property world, namely dependency properties. They introduce some nice new features such as property value inheritance and change notification. You can imagine that most of the WPF properties are dependency properties.</p>
<p>Like almost anything else, dependency properties are coming in multiple variations. The first is a “simple” dependency property, and the second is an <em>attached </em>dependency property. More info about the latter is in the end of this post.</p>
<p>What do we need to define a classic dependency property (that is not an attached one)? Three things:</p>
<ul>
<li>defining the property</li>
<li>registering it</li>
<li>wrapping it within a normal .NET property</li>
</ul>
<p>Well, that doesn’t sound like a big issue, so let’s define one!</p>
<p>First we need to define the property – in the class we’ll use it in. To do so, we need to add a static field of type DependencyProperty (this field might be shared with other elements, so it’s a good point to define it as static). Also, you need to define the field with the readonly keyword, so it can only be set in a static constructor. The whole code might look as follows:<span id="more-727"></span></p>
<p><code>public static readonly DependencyProperty ColorProperty;</code></p>
<p>Now you need to register it with the class you’d like to use. We created a static readonly field, so the best way to set it is a static constructor. To register a dependency property, you can define five things:</p>
<ul>
<li>Property name</li>
<li>Data type used</li>
<li>Owner type</li>
<li>A FramewokrPropertyMetadata object – optional</li>
<li>A validation callback – optional</li>
</ul>
<p>So working with the previous example, you could do something like this in the static constructor:</p>
<p><code>ColorProperty = DependencyProperty.Register(“Color”, typeof(Color), typeof(FrameworkElement));</code></p>
<p>The last two things are FrameworkPropertyMetadata and the validation callback – they deserve some explanation. The FrameworkPropertyMetadata class has some Boolean flags you can set, and they can indicate a bunch of things, like if the property affects the rendering of the item, is it inheritable by child properties, a default value, etc. An interesting feature is that it lets you define two callback methods – CoerceValueCallback and PropertyChangedCallback. More info on them later.</p>
<p>A validation callback is a bit limited callback method you can define in the DependencyProperty.Register method. Because it knows of only the value to be validated, and not the context, you can do some basic validation by it (like for example the value isn’t negative). But you can’t check if the value is bigger than another value in the same object. That’s what Coercion callbacks are for.</p>
<p>OK, the last thing to do when you work with a normal dependency property is to wrap it within a normal .NET property. You should use the GetValue and SetValue methods, and never place any validation logic inside your property getters and setters, because they can be bypassed by WPF. So to stick with our color example, here’s what you’d do:</p>
<p><code>public Color Color<br />
{<br />
get { return (Color) GetValue(ColorProperty);}<br />
set { SetValue(ColorProperty, value); }<br />
}</code></p>
<p>And you’re done. I told you in the very beginning that there are two types of dependency properties. That was the first one, now let’s see the second. It’s called an attached dependency property, and the main difference is that it’s an attached property.</p>
<p>There isn’t much difference between defining an attached and a normal dependency property. You define it as a static readonly field, but you use the RegisterAttached method of the DependencyProperty class. You define static getter and setter methods, with the name GetPropertyName and SetPropertyName, as follows:</p>
<p><code>public static Color GetColor(UIElement element)<br />
{<br />
return (Color) element.GetValue(UIElement.Color);<br />
}<br />
public static void SetColor(UIElement element, Color value)<br />
{<br />
element.SetValue(UIElement.Color, value);<br />
}</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/727/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/727/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/727/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/727/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/727/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/727/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/727/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/727/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=727&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/02/20/implement-dependency-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
		<item>
		<title>Implement drag and drop operations within and across applications</title>
		<link>http://konczuras.wordpress.com/2011/02/16/implement-drag-and-drop-operations-within-and-across-applications/</link>
		<comments>http://konczuras.wordpress.com/2011/02/16/implement-drag-and-drop-operations-within-and-across-applications/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 20:08:04 +0000</pubDate>
		<dc:creator>Gergely Koncz</dc:creator>
				<category><![CDATA[Enhancing the Functionality and Usability of a Solution]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[WPF 70-511]]></category>
		<category><![CDATA[Drag and drop]]></category>

		<guid isPermaLink="false">http://konczuras.wordpress.com/?p=725</guid>
		<description><![CDATA[Dragging and dropping pieces of information is fun. Sometimes I do it too – maybe once a week, maybe twice. The point is that you can do it in WPF, and as the title says: within and across applications. Let’s see a fairly basic example: drag something and drop it to another control. First we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=725&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Dragging and dropping pieces of information is fun. Sometimes I do it too – maybe once a week, maybe twice. The point is that you can do it in WPF, and as the title says: within and across applications.</p>
<p>Let’s see a fairly basic example: drag something and drop it to another control. First we need to handle the MouseDown event on the source control (you must hold down the mouse, move it to another place, and release it there). We need a method there:</p>
<p><code>private void source_MouseDown(….)<br />
{<br />
Label lab = (Label) sender;<br />
DragDrop.DoDragDrop(lab, lab.Content, DragDropEffects.Copy);<br />
}</code></p>
<p>Then you need to handle the target’s drop event, like this:</p>
<p><code>private void target_Drop(object sender, DragEventArgs e)<br />
{<br />
 ((Label)sender).Content = e.Data.GetData(DataFormats.Text);<br />
}</code></p>
<p>These code samples were from the book Pro WPF 4 in C# 2010.</p>
<p>Of course you could improve this drag and drop experience to check whether or not data is present before “dropping” it on the target. There’s an event just for that, and it’s called DragEnter. A perfect candidate to check things like the format and the availability of the data to be dropped.</p>
<p>If you’d like to drag and drop across applications, then I have a nice link for you. It’s a <a href="http://scottgarland.com/Post/Display/WPF_Drag_and_Drop_Image_Between_Applications">little code</a> written by Scott Garland who seemed to be a little upset when he tried to do the thing. Anyway, don’t give up the hope – you need a class implementing ISerializable or IDataObject to begin with, and the rest will be simple…</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/konczuras.wordpress.com/725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/konczuras.wordpress.com/725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/konczuras.wordpress.com/725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/konczuras.wordpress.com/725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/konczuras.wordpress.com/725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/konczuras.wordpress.com/725/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/konczuras.wordpress.com/725/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/konczuras.wordpress.com/725/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=konczuras.wordpress.com&amp;blog=9414682&amp;post=725&amp;subd=konczuras&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://konczuras.wordpress.com/2011/02/16/implement-drag-and-drop-operations-within-and-across-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/73f330670a487544718f89006a3a4246?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">konczuras</media:title>
		</media:content>
	</item>
	</channel>
</rss>
