<?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: How do I insert Separator objects in a data bound MenuItem?</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=23" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=23</link>
	<description>on Silverlight and WPF</description>
	<lastBuildDate>Mon, 02 Aug 2010 17:57:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=23&#038;cpage=1#comment-342</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Mon, 17 Sep 2007 22:59:18 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=23#comment-342</guid>
		<description>Hi Karl,

I&#039;m glad you like the demo.
(And btw it&#039;s not a dumb question at all)

I modified the sample from this post to include some code that gets a handle to a MenuItem that corresponds to a given data item. Once you have a handle to the MenuItem, you can modify any of its properties or add any event handlers you want. Here is the interesting part of the code:

            Source source = this.Resources[&quot;src&quot;] as Source;
            Animal spider = source.AnimalCollection[0] as Animal;
            MenuItem menuItem = myMenu.Items[0] as MenuItem;
            menuItem.IsSubmenuOpen = true;
            MenuItem spiderMenu = menuItem.ItemContainerGenerator.ContainerFromItem(spider) as MenuItem;

I uploaded a project with this code &lt;a href=&quot;http://www.beacosta.com/BlogComments/26InsertingSeparators.zip&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;.

If you want to set properties at the time the MenuItem is created, your best option is to use a Style with a Setter. And if you want to attach an event, you can use a Style with an EventSetter.

Let me know if this answers your question.

And thanks for reading my blog!

Bea</description>
		<content:encoded><![CDATA[<p>Hi Karl,</p>
<p>I&#8217;m glad you like the demo.<br />
(And btw it&#8217;s not a dumb question at all)</p>
<p>I modified the sample from this post to include some code that gets a handle to a MenuItem that corresponds to a given data item. Once you have a handle to the MenuItem, you can modify any of its properties or add any event handlers you want. Here is the interesting part of the code:</p>
<p>            Source source = this.Resources["src"] as Source;<br />
            Animal spider = source.AnimalCollection[0] as Animal;<br />
            MenuItem menuItem = myMenu.Items[0] as MenuItem;<br />
            menuItem.IsSubmenuOpen = true;<br />
            MenuItem spiderMenu = menuItem.ItemContainerGenerator.ContainerFromItem(spider) as MenuItem;</p>
<p>I uploaded a project with this code <a href="http://www.beacosta.com/BlogComments/26InsertingSeparators.zip" rel="nofollow">here</a>.</p>
<p>If you want to set properties at the time the MenuItem is created, your best option is to use a Style with a Setter. And if you want to attach an event, you can use a Style with an EventSetter.</p>
<p>Let me know if this answers your question.</p>
<p>And thanks for reading my blog!</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Shifflett</title>
		<link>http://bea.stollnitz.com/blog/?p=23&#038;cpage=1#comment-341</link>
		<dc:creator>Karl Shifflett</dc:creator>
		<pubDate>Mon, 17 Sep 2007 19:34:20 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=23#comment-341</guid>
		<description>Hello Beatriz,

First I love this demo!  

Now, sorry to ask a dumb question.  

Using your example, how would get access to the MenuItem as it&#039;s being created so that you could add InputGestureText or possibly add an event handler?

I understand that the DataContect of the automatically created MenuItem is the Animal class, but I was hoping to have some more control over the MenuItem that gets created.

Thank you!

Karl</description>
		<content:encoded><![CDATA[<p>Hello Beatriz,</p>
<p>First I love this demo!  </p>
<p>Now, sorry to ask a dumb question.  </p>
<p>Using your example, how would get access to the MenuItem as it&#8217;s being created so that you could add InputGestureText or possibly add an event handler?</p>
<p>I understand that the DataContect of the automatically created MenuItem is the Animal class, but I was hoping to have some more control over the MenuItem that gets created.</p>
<p>Thank you!</p>
<p>Karl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=23&#038;cpage=1#comment-153</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Tue, 04 Apr 2006 22:07:34 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=23#comment-153</guid>
		<description>Hi Marc,

Yes, that is a good observation. The ObservableCollection does keep track of where the separators should go, apart from keeping track of the data itself. If this is a concern for your particular application, it wouldn&#039;t be hard to split this knowledge into a two-tier data source. One class would only have the information about the data, and the other would store the locations of where to insert the separators.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Marc,</p>
<p>Yes, that is a good observation. The ObservableCollection does keep track of where the separators should go, apart from keeping track of the data itself. If this is a concern for your particular application, it wouldn&#8217;t be hard to split this knowledge into a two-tier data source. One class would only have the information about the data, and the other would store the locations of where to insert the separators.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc</title>
		<link>http://bea.stollnitz.com/blog/?p=23&#038;cpage=1#comment-152</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Tue, 04 Apr 2006 03:52:52 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=23#comment-152</guid>
		<description>Hallo Beatriz,

It is interesting to note that this solution requires the bound observable collection to depart from a pure &#039;business layer structure&#039;, given the explicit presence of a &#039;separator&#039; object within the collection.

With kind regards,

Marc</description>
		<content:encoded><![CDATA[<p>Hallo Beatriz,</p>
<p>It is interesting to note that this solution requires the bound observable collection to depart from a pure &#8216;business layer structure&#8217;, given the explicit presence of a &#8217;separator&#8217; object within the collection.</p>
<p>With kind regards,</p>
<p>Marc</p>
]]></content:encoded>
	</item>
</channel>
</rss>
