<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: WPFix Part 3 (Extension Methods)</title>
	<atom:link href="http://www.fikrimvar.net/lestirelim/?feed=rss2&#038;p=23" rel="self" type="application/rss+xml" />
	<link>http://www.fikrimvar.net/lestirelim/?p=23</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 26 Mar 2012 11:34:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: M. Orçun Topdağı</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-37</link>
		<dc:creator>M. Orçun Topdağı</dc:creator>
		<pubDate>Fri, 17 Apr 2009 06:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-37</guid>
		<description>Charles, I just read your comment, I had 12 days at work to completely rewrite a 12 month project. I wasn&#039;t aware of such problem, I will take a look at it as soon as I can.</description>
		<content:encoded><![CDATA[<p>Charles, I just read your comment, I had 12 days at work to completely rewrite a 12 month project. I wasn&#8217;t aware of such problem, I will take a look at it as soon as I can.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-36</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Fri, 10 Apr 2009 14:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-36</guid>
		<description>Doh- the blog choked on the xaml...
Perhaps escaping the lt/gts will fix it:

&lt;ListBox.ItemTemplate&gt;
   &lt;DataTemplate&gt;
      &lt;TextBlock x:Name=&#039;duration&#039; Text=&#039;{Binding Source={x:Static sys:DateTime.Now}, 
         Converter={fix:Lambda &quot;v=&gt;v.ToString().ToUpper()&quot;}}&#039;/&gt;
   &lt;/DataTemplate&gt;
&lt;/ListBox.ItemTemplate&gt;</description>
		<content:encoded><![CDATA[<p>Doh- the blog choked on the xaml&#8230;<br />
Perhaps escaping the lt/gts will fix it:</p>
<p>&lt;ListBox.ItemTemplate&gt;<br />
   &lt;DataTemplate&gt;<br />
      &lt;TextBlock x:Name=&#8217;duration&#8217; Text=&#8217;{Binding Source={x:Static sys:DateTime.Now},<br />
         Converter={fix:Lambda &#8220;v=&gt;v.ToString().ToUpper()&#8221;}}&#8217;/&gt;<br />
   &lt;/DataTemplate&gt;<br />
&lt;/ListBox.ItemTemplate&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-35</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Fri, 10 Apr 2009 14:54:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-35</guid>
		<description>Hello,

Nice article!  I really like the concept, but I&#039;m running into a problem using this in one particular scenario.  When trying to use the is a DataTemplate for a listbox using the following markup

            
                
                    v.ToString().ToUpper()&quot;}}&#039;/&gt;
                    &lt;!----&gt;
                
            

I get the following  error:

Unrecognized property &#039;v&#039; for type &#039;WPFix.LambdaExtension&#039; found while parsing markup extension. 


Any suggestions as to why this doesn&#039;t work when used in a DataTemplate?</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Nice article!  I really like the concept, but I&#8217;m running into a problem using this in one particular scenario.  When trying to use the is a DataTemplate for a listbox using the following markup</p>
<p>                    v.ToString().ToUpper()&#8221;}}&#8217;/&gt;<br />
                    &lt;!&#8212;-&gt;</p>
<p>I get the following  error:</p>
<p>Unrecognized property &#8216;v&#8217; for type &#8216;WPFix.LambdaExtension&#8217; found while parsing markup extension. </p>
<p>Any suggestions as to why this doesn&#8217;t work when used in a DataTemplate?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hierogli</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-34</link>
		<dc:creator>Hierogli</dc:creator>
		<pubDate>Fri, 27 Feb 2009 10:21:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-34</guid>
		<description>sorry, not general lamda expressions, i have problems only with lambda expression extension in this way.</description>
		<content:encoded><![CDATA[<p>sorry, not general lamda expressions, i have problems only with lambda expression extension in this way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hierogli</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-33</link>
		<dc:creator>Hierogli</dc:creator>
		<pubDate>Fri, 27 Feb 2009 09:27:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-33</guid>
		<description>I&#039;m not sure the overall value of the lambda expressions. Lambda expression written in xmls will be checked and evaluated in runtime, you lose almost all positive effects of type safety.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure the overall value of the lambda expressions. Lambda expression written in xmls will be checked and evaluated in runtime, you lose almost all positive effects of type safety.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lloyd</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-32</link>
		<dc:creator>Lloyd</dc:creator>
		<pubDate>Mon, 01 Dec 2008 23:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-32</guid>
		<description>Ho.. indeed, it&#039;s exactly the same problem as me!

And.. you said MS is offering a standart alternative?!
Never heard about it, you got me curious, could you elaborate?

And you are making a nw version, cool!

Thanks for your answer!</description>
		<content:encoded><![CDATA[<p>Ho.. indeed, it&#8217;s exactly the same problem as me!</p>
<p>And.. you said MS is offering a standart alternative?!<br />
Never heard about it, you got me curious, could you elaborate?</p>
<p>And you are making a nw version, cool!</p>
<p>Thanks for your answer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M. Orçun Topdağı</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-31</link>
		<dc:creator>M. Orçun Topdağı</dc:creator>
		<pubDate>Fri, 28 Nov 2008 20:05:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-31</guid>
		<description>I waited Microsoft long enough, more than year, -which I can hardly believe-, to offer a standard alternative. I am planning to take some time for a new version. 

@Lloyd
Please take a look at the comments at part 2.</description>
		<content:encoded><![CDATA[<p>I waited Microsoft long enough, more than year, -which I can hardly believe-, to offer a standard alternative. I am planning to take some time for a new version. </p>
<p>@Lloyd<br />
Please take a look at the comments at part 2.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lloyd</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-30</link>
		<dc:creator>Lloyd</dc:creator>
		<pubDate>Thu, 27 Nov 2008 01:01:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-30</guid>
		<description>Mysterious problem with LambdaExtension!

I&#039;m trying to make a UIElement visible depending n some boolean, and it throws some mysterious looking exception. I wonder if you could share some light one the problem?

Here is the code which I&#039;m attempting to run:

&lt;Window 
  x:Class=&quot;VisiTest.Window1&quot;
  xlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
  xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
  xmlns:pix=&quot;clr-namespace:WPFix;assembly=WPFix&quot;
    Title=&quot;Window1&quot; Height=&quot;300&quot; Width=&quot;300&quot;&gt;
	&lt;StackPanel Orientation=&quot;Vertical&quot;&gt;
		&lt;CheckBox x:Name=&quot;cVisi&quot; Content=&quot;Button is visible&quot;/&gt;
		
		&lt;Button Content=&quot;OK&quot;
				Visibility=&quot;{Binding IsChecked, ElementName=cVisi, Converter={pix:Lambda &#039;b=&gt;b?Visibility.Visible:Visibility.Collapsed&#039;}}&quot;/&gt;
	&lt;/StackPanel&gt;
&lt;/Window&gt;</description>
		<content:encoded><![CDATA[<p>Mysterious problem with LambdaExtension!</p>
<p>I&#8217;m trying to make a UIElement visible depending n some boolean, and it throws some mysterious looking exception. I wonder if you could share some light one the problem?</p>
<p>Here is the code which I&#8217;m attempting to run:</p>
<p>&lt;Window<br />
  x:Class=&#8221;VisiTest.Window1&#8243;<br />
  xlns=&#8221;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;<br />
  xmlns:x=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8221;<br />
  xmlns:pix=&#8221;clr-namespace:WPFix;assembly=WPFix&#8221;<br />
    Title=&#8221;Window1&#8243; Height=&#8221;300&#8243; Width=&#8221;300&#8243;&gt;<br />
	&lt;StackPanel Orientation=&#8221;Vertical&#8221;&gt;<br />
		&lt;CheckBox x:Name=&#8221;cVisi&#8221; Content=&#8221;Button is visible&#8221;/&gt;</p>
<p>		&lt;Button Content=&#8221;OK&#8221;<br />
				Visibility=&#8221;{Binding IsChecked, ElementName=cVisi, Converter={pix:Lambda &#8216;b=&gt;b?Visibility.Visible:Visibility.Collapsed&#8217;}}&#8221;/&gt;<br />
	&lt;/StackPanel&gt;<br />
&lt;/Window&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M. Orçun Topdağı</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-29</link>
		<dc:creator>M. Orçun Topdağı</dc:creator>
		<pubDate>Sun, 02 Nov 2008 09:30:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-29</guid>
		<description>Thanks for the effort. Glad to see people who wants to contribute.
There are, I believe, similar solutions which might be leaner on the XAML side. I am not very fond of writing actual code as a comment. However, I will update the CodePlex project as soon as I find a couple of hours.</description>
		<content:encoded><![CDATA[<p>Thanks for the effort. Glad to see people who wants to contribute.<br />
There are, I believe, similar solutions which might be leaner on the XAML side. I am not very fond of writing actual code as a comment. However, I will update the CodePlex project as soon as I find a couple of hours.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chaiguy1337</title>
		<link>http://www.fikrimvar.net/lestirelim/?p=23#comment-28</link>
		<dc:creator>chaiguy1337</dc:creator>
		<pubDate>Sun, 02 Nov 2008 00:29:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.fikrimvar.net/lestirelim/?p=23#comment-28</guid>
		<description>Hi. I&#039;ve done a little fiddling and managed to come up with a way for null values to be supported, but it involves explicitly mentioning the types, rather than inferring them at convert time. (I&#039;m currently using ConverterParameter to pass the type to the convert function since it was not being used in your implementation).

Thus it&#039;s not the most elegant or convenient syntax, but at least it works. I did it in such a way that it&#039;s only required if a value could be null; therefore if the ConverterParameter isn&#039;t provided it defaults to its original behavior.

Here are the relevant changes:

public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {
	if ( this.ForwardOperation == null ) {
		if ( value == null &amp;&amp; parameter == null )
			return Binding.DoNothing;
		ForwardOperation = ConstructOperation( this.Forward, value, parameter as Type, targetType );
	}
	try {
		return this.ForwardOperation.DynamicInvoke( value );
	} catch {
		return Binding.DoNothing;
	}
}

private Delegate ConstructOperation( string code, object value, Type valueType, Type targetType ) {
	int opi = code.IndexOf( &quot;=&gt;&quot; );
	if ( opi &quot; );
	string param = code.Substring( 0, opi );
	string body = code.Substring( opi + 2 );
	ParameterExpression p = Expression.Parameter( valueType != null ? valueType : value.GetType(), param );
	LambdaExpression lambda = DynamicExpression.ParseLambda( this.TypeResolver, new ParameterExpression[] { p }, targetType, body, value );
	return lambda.Compile();
}</description>
		<content:encoded><![CDATA[<p>Hi. I&#8217;ve done a little fiddling and managed to come up with a way for null values to be supported, but it involves explicitly mentioning the types, rather than inferring them at convert time. (I&#8217;m currently using ConverterParameter to pass the type to the convert function since it was not being used in your implementation).</p>
<p>Thus it&#8217;s not the most elegant or convenient syntax, but at least it works. I did it in such a way that it&#8217;s only required if a value could be null; therefore if the ConverterParameter isn&#8217;t provided it defaults to its original behavior.</p>
<p>Here are the relevant changes:</p>
<p>public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) {<br />
	if ( this.ForwardOperation == null ) {<br />
		if ( value == null &amp;&amp; parameter == null )<br />
			return Binding.DoNothing;<br />
		ForwardOperation = ConstructOperation( this.Forward, value, parameter as Type, targetType );<br />
	}<br />
	try {<br />
		return this.ForwardOperation.DynamicInvoke( value );<br />
	} catch {<br />
		return Binding.DoNothing;<br />
	}<br />
}</p>
<p>private Delegate ConstructOperation( string code, object value, Type valueType, Type targetType ) {<br />
	int opi = code.IndexOf( &#8220;=&gt;&#8221; );<br />
	if ( opi &#8221; );<br />
	string param = code.Substring( 0, opi );<br />
	string body = code.Substring( opi + 2 );<br />
	ParameterExpression p = Expression.Parameter( valueType != null ? valueType : value.GetType(), param );<br />
	LambdaExpression lambda = DynamicExpression.ParseLambda( this.TypeResolver, new ParameterExpression[] { p }, targetType, body, value );<br />
	return lambda.Compile();<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
