<?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>Alex Sarafian as Developer &#187; WPF</title>
	<atom:link href="http://sarafianalex.wordpress.com/tag/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://sarafianalex.wordpress.com</link>
	<description>Adventures in C# Land and some SQL</description>
	<lastBuildDate>Fri, 04 Sep 2009 11:27:50 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='sarafianalex.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/ea38bb69738d229a89ab00b82aad64b7?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Alex Sarafian as Developer &#187; WPF</title>
		<link>http://sarafianalex.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sarafianalex.wordpress.com/osd.xml" title="Alex Sarafian as Developer" />
		<item>
		<title>Set a value to a control only in design mode</title>
		<link>http://sarafianalex.wordpress.com/2008/06/14/set-a-value-to-a-control-only-in-design-mode/</link>
		<comments>http://sarafianalex.wordpress.com/2008/06/14/set-a-value-to-a-control-only-in-design-mode/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 23:19:09 +0000</pubDate>
		<dc:creator>Sarafian Alex</dc:creator>
				<category><![CDATA[.NET C#]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://sarafianalex.wordpress.com/2008/06/14/set-a-value-to-a-control-only-in-design-mode/</guid>
		<description><![CDATA[I have been working on making my project localizable. I made it using Resources just like skins but this will be another post.
The final problem I encountered was that there was no design time support to show a dummy text, in a Button for example. Everything was going well except from the design part which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarafianalex.wordpress.com&blog=2367780&post=23&subd=sarafianalex&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have been working on making my project localizable. I made it using Resources just like skins but this will be another post.</p>
<p>The final problem I encountered was that there was no design time support to show a dummy text, in a Button for example. Everything was going well except from the design part which was not that significant for me, but as I&#8217;m the writer of the company&#8217;s new framework it might be for others.</p>
<p>So can you set a value to <span style="color:#2b91af;">DependencyProperty</span> of a <span style="color:#2b91af;">DependencyObject </span>only to in DesignMode?</p>
<p>Using a custom <span style="color:#2b91af;">MarkupExtension</span> you can. Here is the implementation</p>
<blockquote>
<pre>[<span style="color:#2b91af;">ContentProperty</span>(<span style="color:#a31515;">"Value"</span>)]
<span style="color:#0000ff;">public class  </span><span style="color:#2b91af;">DesignTimeDummy </span>: <span style="color:#2b91af;">MarkupExtension</span>
{
<span style="color:#0000ff;">    public </span>DesignTimeDummy()    {

    }
    <span style="color:#0000ff;">public object  </span>Value { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
    <span style="color:#0000ff;">public override object  </span>ProvideValue
          (<span style="color:#2b91af;">IServiceProvider </span>serviceProvider)
    {
        <span style="color:#0000ff;">if </span>(Helpers.<span style="color:#2b91af;">Designer</span>.InDesignMode)
        {

            <span style="color:#0000ff;">return </span>Value;

        }
        <span style="color:#0000ff;">return </span><span style="color:#2b91af;">DependencyProperty</span>.UnsetValue;
    }

}</pre>
</blockquote>
<p>And this is how you can use it</p>
<blockquote>
<p align="left"><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">Button </span><span style="color:#ff0000;">Style</span><span style="color:#0000ff;">=&#8221;{</span><span style="color:#a31515;">DynamicResource </span><span style="color:#ff0000;">styleName</span><span style="color:#0000ff;">}&#8221; </span><span style="color:#ff0000;">Content</span><span style="color:#0000ff;">=&#8221;{</span><span style="color:#a31515;">CoreME</span><span style="color:#0000ff;">:</span><span style="color:#a31515;">DesignTimeDummy V</span><span style="color:#ff0000;">alue</span><span style="color:#0000ff;">=DesignContentValue}&#8221;/&gt;</span></p>
</blockquote>
<p>or</p>
<p><span style="color:#0000ff;"></p>
<blockquote>
<pre><span style="color:#0000ff;">&lt;</span><span style="color:#a31515;">Button </span><span style="color:#ff0000;">Style</span><span style="color:#0000ff;">="{</span><span style="color:#a31515;">DynamicResource </span><span style="color:#ff0000;">cancelButtonStyle</span><span style="color:#0000ff;">}" &gt;
  &lt;</span><span style="color:#a31515;">Button.Content</span><span style="color:#0000ff;">&gt;
    &lt;</span><span style="color:#a31515;">CoreME</span><span style="color:#0000ff;">:</span><span style="color:#a31515;">DesignTimeDummy</span><span style="color:#0000ff;">&gt;
      </span><span style="color:#a31515;">Dummy
</span><span style="color:#0000ff;">    &lt;/</span><span style="color:#a31515;">CoreME</span><span style="color:#0000ff;">:</span><span style="color:#a31515;">DesignTimeDummy</span><span style="color:#0000ff;">&gt;
  &lt;/</span><span style="color:#a31515;">Button.Content</span><span style="color:#0000ff;">&gt;
&lt;/</span><span style="color:#a31515;">Button</span><span style="color:#0000ff;">&gt;</span></pre>
</blockquote>
<p><span style="color:#0000ff;"></span></p>
<p><span style="color:blue;"><span style="color:#000000;">where CoreME is an xmlns defined namespace shortcut</span></p>
<p></span></span></p>
<p> </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sarafianalex.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sarafianalex.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarafianalex.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarafianalex.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarafianalex.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarafianalex.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarafianalex.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarafianalex.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarafianalex.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarafianalex.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarafianalex.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarafianalex.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarafianalex.wordpress.com&blog=2367780&post=23&subd=sarafianalex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sarafianalex.wordpress.com/2008/06/14/set-a-value-to-a-control-only-in-design-mode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/64f00567ef7dda3ec36dcf0e01043d11?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sarafian</media:title>
		</media:content>
	</item>
		<item>
		<title>In design mode</title>
		<link>http://sarafianalex.wordpress.com/2008/06/14/in-design-mode/</link>
		<comments>http://sarafianalex.wordpress.com/2008/06/14/in-design-mode/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 22:59:44 +0000</pubDate>
		<dc:creator>Sarafian Alex</dc:creator>
				<category><![CDATA[.NET C#]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://sarafianalex.wordpress.com/2008/06/14/in-design-mode/</guid>
		<description><![CDATA[WPF project has begun and I have been continuously finding new things. I&#8217;m very excited, mainly because what I have accomplished to today. Maybe I will write about it.
Many thanks to fellows like Josh,Karl and Sasha for the knowledge I have acquired from them since Summer 2007.
One of the things I needed, for my next [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarafianalex.wordpress.com&blog=2367780&post=22&subd=sarafianalex&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>WPF project has begun and I have been continuously finding new things. I&#8217;m very excited, mainly because what I have accomplished to today. Maybe I will write about it.</p>
<p>Many thanks to fellows like Josh,Karl and Sasha for the knowledge I have acquired from them since Summer 2007.</p>
<p>One of the things I needed, for my next post, is to know if code is running in DesignMode or not.</p>
<p>So here is the class I wrote</p>
<pre><span style="color:#0000ff;">public static class </span><span style="color:#2b91af;">Designer
</span>{
    <span style="color:#0000ff;">private static </span><span style="color:#2b91af;">DependencyObject </span>dummy = <span style="color:#0000ff;">new </span><span style="color:#2b91af;">DependencyObject</span>();
    <span style="color:#0000ff;">public static bool </span>InDesignMode
    {
        <span style="color:#0000ff;">get </span>{ <span style="color:#0000ff;">return </span><span style="color:#2b91af;">DesignerProperties</span>.GetIsInDesignMode(dummy); }
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/sarafianalex.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/sarafianalex.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sarafianalex.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sarafianalex.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sarafianalex.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sarafianalex.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sarafianalex.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sarafianalex.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sarafianalex.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sarafianalex.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sarafianalex.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sarafianalex.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sarafianalex.wordpress.com&blog=2367780&post=22&subd=sarafianalex&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sarafianalex.wordpress.com/2008/06/14/in-design-mode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/64f00567ef7dda3ec36dcf0e01043d11?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sarafian</media:title>
		</media:content>
	</item>
	</channel>
</rss>