<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx</link><description>I've previously written that one of my ContextMenu test cases for the April '10 release of the Silverlight Toolkit was to implement a quick "split button" control for Silverlight using Button and ContextMenu . Though it wasn't my goal to build a general</description><dc:language>en</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10290674</link><pubDate>Wed, 04 Apr 2012 08:51:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10290674</guid><dc:creator>Femke</dc:creator><description>&lt;p&gt;Hi Kainhart,&lt;/p&gt;
&lt;p&gt;In addition to my previous question, I found a workaround for context menu showing when loading the SplitButton, with this workaround the Command binding will still work when using the SplitButton on a DataTemplate:&lt;/p&gt;
&lt;p&gt;On the OnApplyTemplate hide the contextmenu:&lt;/p&gt;
&lt;p&gt;_contextMenu.Visibility = System.Windows.Visibility.Hidden;&lt;/p&gt;
&lt;p&gt;On OpenButtonMenu make the contextmenu visible again:&lt;/p&gt;
&lt;p&gt;_contextMenu.Visibility = System.Windows.Visibility.Visible;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10290674" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10194090</link><pubDate>Tue, 09 Aug 2011 17:39:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10194090</guid><dc:creator>David Anson</dc:creator><description>&lt;p&gt;Aleks,&lt;/p&gt;
&lt;p&gt;I explain why the ContextMenu is set as a logical child in the second paragraph of the post above. As you&amp;#39;ve also discovered, certain things (ex: DataContext, RoutedCommands) don&amp;#39;t work otherwise. There may be another way to get this all working, but that what I found worked at the time. :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10194090" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10194000</link><pubDate>Tue, 09 Aug 2011 13:10:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10194000</guid><dc:creator>Aleks</dc:creator><description>&lt;p&gt;Humm in fact it didn&amp;#39;t work.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying to understand because the context menu appear in the window while the code is parsing the logical tree wich is not really nice.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10194000" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10193995</link><pubDate>Tue, 09 Aug 2011 12:54:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10193995</guid><dc:creator>Aleks</dc:creator><description>&lt;p&gt;Hi David,&lt;/p&gt;
&lt;p&gt;Don&amp;#39;t understand why you are adding the contextmenu as a logical child.&lt;/p&gt;
&lt;p&gt;I just put it in the button context Menu and it works : this.ContextMenu = _contextMenu;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10193995" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10182977</link><pubDate>Mon, 04 Jul 2011 21:57:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10182977</guid><dc:creator>David Anson</dc:creator><description>&lt;p&gt;Helge Klein,&lt;/p&gt;
&lt;p&gt;Glad it worked for you - thanks for the message! :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10182977" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10182970</link><pubDate>Mon, 04 Jul 2011 21:17:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10182970</guid><dc:creator>Helge Klein</dc:creator><description>&lt;p&gt;I just implemented the buttons in my project. Works like a treat! Thank you very much for publishing this.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10182970" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10105149</link><pubDate>Wed, 15 Dec 2010 07:05:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10105149</guid><dc:creator>David Anson</dc:creator><description>&lt;p&gt;jpierson,&lt;/p&gt;
&lt;p&gt;If I had to guess at why RelativeSource wouldn&amp;#39;t work here, my first thought would be that it might be due to the ContextMenu-imposed Popup sitting between the MenuItems and the rest of the page. If so, one possible workaround might be to use something like &amp;quot;{Binding ElementName=MyWindowName, Path=Background}&amp;quot; instead - though that might suffer from the same root problem...&lt;/p&gt;
&lt;p&gt;Big thanks for the detailed information and for sharing your findings!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10105149" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10104879</link><pubDate>Tue, 14 Dec 2010 19:29:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10104879</guid><dc:creator>kainhart</dc:creator><description>&lt;p&gt;I&amp;#39;ve just run into another issue this time with RelativeSource binding defined on properties of the MenuItems used in my sample application. &lt;/p&gt;
&lt;p&gt;In my case I need to access a property on one of the parent controls such as a Window or UserControl. To bind to the property I&amp;#39;m using a binding that looks like the example below.&lt;/p&gt;
&lt;p&gt;&amp;lt;MenuItem Background=&amp;quot;{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=Background}&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;In my real project I&amp;#39;m binding something a little more specific than just the Background of the Window but the point is still the same. Also I&amp;#39;m not sure whether this is a problem with SplitButton implementation yet or just something that would occur with all bindings specified to items within a ContextMenu. If I find any more details I&amp;#39;ll follow up here to help others that may need to do something similar.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10104879" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10095291</link><pubDate>Tue, 23 Nov 2010 07:25:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095291</guid><dc:creator>David Anson</dc:creator><description>&lt;p&gt;jpierson,&lt;/p&gt;
&lt;p&gt;Great stuff - thank you very much for that detailed write-up! I don&amp;#39;t have specific plans to update SplitButton right now, but I&amp;#39;ve added a note to my TODO list referencing the issue you report and your proposed fix. For what it&amp;#39;s worth, I&amp;#39;m also not a big fan of private reflection - but maybe when I (or you) revisit this at some future date, an alternate solution will present itself... :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095291" width="1" height="1"&gt;</description></item><item><title>re: Banana SplitButton [A WPF-specific fix for SplitButton and some code analysis improvements for the Silverlight version, too]</title><link>http://blogs.msdn.com/b/delay/archive/2010/07/06/banana-splitbutton-a-wpf-specific-fix-for-splitbutton-and-some-code-analysis-improvements-for-the-silverlight-version-too.aspx#10095137</link><pubDate>Mon, 22 Nov 2010 21:33:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10095137</guid><dc:creator>kainhart</dc:creator><description>&lt;p&gt;Delay,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve confirmed that calling the private HookupParentPopup of the ContextMenu through reflection before attempting to do a parent lookup through the logical tree that everything seems to workout great. Even though it&amp;#39;s not recommended to call private methods through reflection, at this point this seems to be the only workaround so I&amp;#39;m going to implement it for my case. &lt;/p&gt;
&lt;p&gt;var hookupParentPopupMethod = _contextMenu.GetType().GetMethod(&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;quot;HookupParentPopup&amp;quot;, &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);&lt;/p&gt;
&lt;p&gt;hookupParentPopupMethod.Invoke(_contextMenu, null);&lt;/p&gt;
&lt;p&gt;While looking over the internal code for ContextMenu one thing that I did also learn is that this method gets called when the IsOpen is set to true meaning that there is no reason to wait until after the logical tree lookup to set IsOpen to false. This means that one could set the IsOpen to true and then set it false directly after that in order to minimize how long the ContextMenu will flash on the screen. I still opt for the reflection call to HookupParentPopup myself until something better comes along.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10095137" width="1" height="1"&gt;</description></item></channel></rss>