0

我有一个 .net 4.5 WPF 应用程序,它会自动(未额外编码)在任务栏中的 JumpList 中创建最近的条目。我想将这些 JumpList 项绑定到 RibbonApplicationMenu。我试图像这样获取当前的 JumpList:

this.JumpList = JumpList.GetJumpList(App.Current);

但我无法将列表绑定到 RibbonApplicationMenu。

                   <RibbonApplicationMenu.AuxiliaryPaneContent>
                    <RibbonGallery CanUserFilter="False" ScrollViewer.VerticalScrollBarVisibility="Auto" >
                        <RibbonGalleryCategory Header="Recent Documents" Background="Transparent" >
                            <JumpList JumpList="{Binding JumpList}"/>
                        </RibbonGalleryCategory>
                    </RibbonGallery>
                </RibbonApplicationMenu.AuxiliaryPaneContent>

如何在不创建自己的列表的情况下将最近的列表放入我的 RibbonApplicationMenu。

编辑

我在我的 MainWpf 构造函数中这样做。

        JumpList pJumpList = JumpList.GetJumpList(Application.Current);
        pJumpList.ShowFrequentCategory = false;
        pJumpList.ShowRecentCategory = true;

        foreach (var item in this.pJumpList.JumpItems)
        {
            JumpPath path = item as JumpPath;
            this.JumpListCollection.Add(path.Path);
        }

我想从 RibbonMenu 的 Jumplist 中获取当前最近的项目

在此处输入图像描述 在此处输入图像描述

这个最近的项目是由 Windows 而不是我的应用程序中的代码创建的

4

1 回答 1

0

In the above code JumpList control doesnot have property to hold the list. Refer the below code. I have used a RibbonGallery.

 <Ribbon>
    <Ribbon.ApplicationMenu>
        <RibbonApplicationMenu Label="test">
            <RibbonApplicationMenuItem Header="Test" />
            <RibbonApplicationMenu.AuxiliaryPaneContent>
                <RibbonGallery CanUserFilter="False" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding JumpListMyApp}">                        
                </RibbonGallery>
            </RibbonApplicationMenu.AuxiliaryPaneContent>
        </RibbonApplicationMenu>
    </Ribbon.ApplicationMenu>
</Ribbon>
class ViewModel
{
    private ObservableCollection<string> myVar=new ObservableCollection<string>();

    public ObservableCollection<string> JumpListMyApp
    {
        get { return myVar; }
        set { myVar = value; }
    }        

    public ViewModel()
    {
        var jump = JumpList.GetJumpList(App.Current);
        foreach (var item in JumpList.GetJumpList(App.Current).JumpItems)
        {
            JumpTask tsk = item as JumpTask;
            JumpListMyApp.Add(tsk.Description);
        }

    }
}
public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
        JumpTask task = new JumpTask
        {
            Title = "Check for Updates",
            Arguments = "/update",
            Description = "Cheks for Software Updates",
            CustomCategory = "Actions",
            IconResourcePath = Assembly.GetEntryAssembly().CodeBase,
            ApplicationPath = Assembly.GetEntryAssembly().CodeBase
        };

        JumpList jumpList = new JumpList();
        jumpList.JumpItems.Add(task);
        jumpList.ShowFrequentCategory = false;
        jumpList.ShowRecentCategory = false;

        JumpList.SetJumpList(Application.Current, jumpList);
    }
}
于 2015-02-04T22:25:56.217 回答