我有一个.net 4.5 WPF应用程序,它自动(不是额外编码)为任务栏中的JumpList创建最近的条目。我想将这些JumpList项绑定到RibbonApplicationMenu。我试着像这样得到当前的JumpList:
this.JumpList = JumpList.GetJumpList(App.Current);
但我无法将List绑定到RibbonApplicationMenu。
<RibbonApplicationMenu.AuxiliaryPaneContent>
<RibbonGallery CanUserFilter="False" ScrollViewer.VerticalScrollBarVisibility="Auto" >
<RibbonGalleryCategory Header="Recent Documents" Background="Transparent" >
<JumpList JumpList="{Binding JumpList}"/>
</RibbonGalleryCategory>
</RibbonGallery>
</RibbonApplicationMenu.AuxiliaryPaneContent>
如何在不创建自己的List的情况下将最近的列表放入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创建的,而不是我的应用程序中的代码
答案 0 :(得分:0)
在上面的代码中,JumpList控件没有用于保存列表的属性。请参阅以下代码。我使用了一个Ribbon Gallery。
<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);
}
}