Search
Saturday, May 18, 2013 ..:: Blendblog.net ::.. Register  Login
 Bloggers Minimize

  
 Sponsors Minimize

 Print   
 Users Online Minimize
Membership Membership:
Latest New User Latest: gyrofan
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 46

People Online People Online:
Visitors Visitors: 3
Members Members: 0
Total Total: 3

Online Now Online Now:

  
 Welcome to blendblog.net! Minimize

If you are a developer or designer who is creating cutting edge user interface experiences using Microsoft Expression Blend you've just found a great resource!  The purpose of this site is to share our experience with this brand new product.  As with any new piece of software there is a ton to discover.  Bugs will be revealed and workarounds discovered, hopefully this can be a resource to share in the discovery process!

While this site will focus largely on Expression Blend, it will also encompass WPF, Visual Studio, Silverlight, and other .net 3.5 technologies as they relate to the creation of great software.

Please login using your Microsoft LiveID or register a new account.  Doing so will let you comment on any of the blog entries on the site.  We look forward to helping you in your endeavors as well as you helping others in theirs!  We'd love to have more bloggers on our site...if you are interested please register and contact us!

Follow us:


  
 Styling items of a WPF RibbonSplitButton (presumably RibbonToggleButton)...don't use a datatemplate! Minimize
Location: BlogsSean Cullinan    
Posted by: Sean Cullinan 6/4/2012 1:55 PM
Here's the scenario, I am using the WPF Ribbon control (release version). I have a RibbonSplitButton and I want it to present a list of checkable RibbonMenuItems based on an obserable collection of object that is populated at runtime. My first inclination is to set the ItemsSource property of the RibbonSplitButton to my observable collection, then create a datatemplate specified as the ItemsTemplate property of the RibbonSplitButton which contains the RibbonMenuItem. This XAML would look like this:
<ribbon:RibbonSplitButton ItemsSource="{MySource}">
     <
ribbon:RibbonSplitButton.ItemTemplate>
         <
DataTemplate>
              <
ribbon:RibbonMenuItem Header="{Binding MyHeader}" IsCheckable="True" IsChecked="{Binding MyIsChecked}"></< font>ribbon:RibbonMenuItem>
         </
DataTemplate>
      </
ribbon:RibbonSplitButton.ItemTemplate>
</
ribbon:RibbonSplitButton>
What this actually yields though is a RibbonMenuItem rendered inside of another RibbonMenuItem. Quite ugly. The reason for this is that the default object type that is used to present an item in a RibbonSplitButton's dropdown IS a RibbonMenuItem. So this datatemplate puts a RibbonMenuItem inside of another. Once I realized this I figured out that using the ItemContainerStyle could get me the result I wanted. The ItemContainerStyle styles the control that is being used to render the item. Since it is a RibbonMenuItem already (which happens to be the object type I wanted to use anyway) we can use Setters bound to our object to acheive our goal. Here's the proper XAML:
<ribbon:RibbonSplitButton x:Key="Hello" ItemsSource="{MySource}">
     <
ribbon:RibbonSplitButton.ItemContainerStyle>
          <Style TargetType="{x:Type ribbon:RibbonMenuItem}">
               <Setter Property="Header" Value="{Binding Name}"/>
               <Setter Property="IsCheckable" Value="True"/>
               <Setter Property="IsChecked" Value="{Binding IsChecked}"/>
          </ Style>
     </ribbon:RibbonSplitButton.ItemContainerStyle>
</ribbon:RibbonSplitButton>
 
I hope this helps someone else out there and I hope it makes sense!
 
Sean
Permalink |  Trackback

Comments (3)   Add Comment
Re: Styling items of a WPF RibbonSplitButton (presumably RibbonToggleButton)...don't use a datatemplate!    By Bibhu on 6/28/2012 4:46 AM
I did not get what is the x:Key="Hello"

Re: Styling items of a WPF RibbonSplitButton (presumably RibbonToggleButton)...don't use a datatemplate!    By stiphy on 7/22/2012 5:06 PM
You could remove that Key, in the example I pasted this from the button was a Hello button and it just came from there. The key isn't relevant in this demo.

Re: Styling items of a WPF RibbonSplitButton (presumably RibbonToggleButton)...don't use a datatemplate!    By fdsa on 3/4/2013 3:34 AM
http://www.dafdfsa.info/ [url=http://www.dafdfsa.info/]fdsg[/url] <a href="http://www.dafdfsa.info/">dafd</a>


Your name:
Title:
Comment:
Add Comment   Cancel 

  
 Search Minimize

  
 Archive Minimize

  
 Blendblog Survey Minimize
Our next client application will be written using:




Which Tablet Do you expect to buy?





Submit Survey  View Results

 Print   
Copyright 2011 by blendblog.net   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2013 by DotNetNuke Corporation