RibbonApplicationMenu Недавний список
У меня есть приложение.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
Эти последние элементы создаются Windows, а не из кода в моем приложении
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);
}
}