Tooltips on bound RecentItemsList

Jul 21, 2009 at 10:35 AM

I've got a RecentFilesLists that I'm populating from a DynamicResource. This works fine as far as building the list is concerned, but what I also want to do is assign the tooltip for each entry (à la Access, Excel etc). The below code works fine as far as far as displaying the Name in the list is concerned, but how can I also assign the tooltips?

 

Thanks :-)

 

<r:RibbonApplicationMenu.RecentItemList>
    <HeaderedContentControl Header="Recent Plans">
        <r:RibbonHighlightingList Name="MRUList"
            MostRecentFileSelected="RibbonHighlightingList_MostRecentFileSelected" 
            ItemsSource="{DynamicResource MostRecentFiles}"
            DisplayMemberPath="Name" />
    </HeaderedContentControl>
</r:RibbonApplicationMenu.RecentItemList>

where MostRecentFiles is an ObservableCollection of RecentFile objects:

public class RecentFile
{
    public RecentFile(string name, string toolTip)
    {
        Name = name;
        Tooltip = toolTip;
    }
    public string Name
    {
        get;
        set;
    }
    public string Tooltip
    {
        get;
        set;
    }
};

 

In my Window_Loaded routine, I'm then setting the resource:

MRUList.ItemsSource = new MostRecentFiles();

Jul 23, 2009 at 11:40 AM

Nobody?

Mar 17, 2010 at 9:46 PM

You probably have figured this out by now, but here is how I solved it for anyone else reading this post.

<r:RibbonApplicationMenu.RecentItemList>
  <HeaderedContentControl Header="Recent Projects">
    <r:RibbonHighlightingList 
      ItemsSource="{Binding Source={x:Static Properties:Settings.Default}, Path=RecentItems }"
      DisplayMemberPath="Name" MostRecentFileSelected="RibbonHighlightingList_MostRecentFileSelected">
        <r:RibbonHighlightingList.Resources>
          <Style TargetType="r:RibbonHighlightingListItem">
            <Setter Property="ToolTip" Value="{Binding Path=ToolTip}" />
          </Style>
       </r:RibbonHighlightingList.Resources>
     </r:RibbonHighlightingList>
   </HeaderedContentControl>
 </r:RibbonApplicationMenu.RecentItemList>
Jun 15, 2010 at 4:41 PM

Thank you bmorrison. This was a great help to me.