【问题标题】:RibbonApplicationMenu Recent listRibbonApplicationMenu 最近的列表
【发布时间】:2015-02-04 20:06:56
【问题描述】:

我有一个 .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 而非我的应用程序中的代码创建的

【问题讨论】:

    标签: c# wpf .net-4.5 ribbon recent-file-list


    【解决方案1】:

    在上面的代码中,JumpList 控件没有保存列表的属性。请参考以下代码。我使用了 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);
        }
    }
    

    【讨论】:

    • 我试过了,但这对我不起作用。看起来我没有得到当前的 JumpList。因为我总是得到一个空异常。但在任务栏中我可以看到 JumpItems。
    • 您可以分享您为应用程序添加的 Jumplist 代码吗?
    • 我发现了一个错误,但我仍然无法正常工作。我想通过我自己创建的 JumpList 获取电流。 this.JumpList = JumpList.GetJumpList(Application.Current);我的 JumpList 没有在我的应用程序中编码,它是由 Windows7 它自己创建的。我没有在 App.cs 中创建 JumpList,所以我无法发布我的代码。也许这是不可能的,但我想尝试让 Windows 自己创建 JumpList。
    • 您是否获得了该应用程序的跳转列表?您是否尝试单击应用程序。您是否为您的应用程序进行了文件关联?
    • 是的文件关联是由于安装程序完成的。不,我没有返回任何 JumpList。我总是得到“空”。当我双击我的文件扩展名时,我的软件会打开并且正在做必须做的事情。双击文件扩展名文件后,在任务栏中的应用程序跳转列表中,我可以看到跳转路径。
    猜你喜欢
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-26
    • 1970-01-01
    • 2012-12-23
    相关资源
    最近更新 更多