in XAML:
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Sub Item 1"/>
<telerik:RadMenuItem Header="Sub Item 2" Style="{StaticResource RadContextMenuItemStyle}" ItemsSource="{Binding Groups}"
MouseEnter="RadMenuItem_MouseEnter" Loaded="RadMenuItem_Loaded" Name="cont">
<telerik:RadMenuItem.ItemContainerStyle>
<Style TargetType="telerik:RadMenuItem">
<Setter Property="Header" Value="{Binding Name}" />
<Setter Property="IsSeparator" Value="{Binding IsSeparator}" />
<Setter Property="CommandParameter" Value="{Binding Id}"/>
</Style>
</telerik:RadMenuItem.ItemContainerStyle>
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="Item 2" ItemsSource="{Binding Groups}"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
in xaml.cs:
private void RadMenuItem_MouseEnter(object sender, MouseEventArgs e)
{
FillMethod();
}
private void FillMethod()
{
if (!f)
{
this.Dispatcher.BeginInvoke(() =>
{
var viewmodel =
(MainPageViewModel)
this.Resources["ViewModel"];
viewmodel.PopupCommand.Execute(null);
});
}
}
private bool f = false;
private void RadMenuItem_Loaded(object sender, RoutedEventArgs e)
{
f = false;
}
in viewmodel:
protected virtual void InvokePopup(object obj)
{
Groups = new List<Group>();
Groups.Add(new Group {Name = "Loading...",Id = "---"});
fillservice.GetGroups();
}
public MainPageViewModel()
{
fillservice = new MockFill();
fillservice.Completeevent += FillContextMenuMethod;
ActionCommand = new DelegateCommand<object>(InvokeAction,CanInvokeAction);
PopupCommand = new DelegateCommand<object>(InvokePopup, CanInvokePopup);
Groups = new List<Group>();
Groups.Add(new Group {Name = "Loading...",Id = "---"});
}
private void FillContextMenuMethod(object sender, GroupsEventArgs e)
{
UIDispatcher.BeginInvoke(() =>
{
Groups = e.Groups.ToList();
});
}
Context menu have a bad behavior, where i change my property group where, submenu is expanding(all arrows had collapsed
for 1-3 seconds and submenu collapsed)
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu>
<telerik:RadMenuItem Header="Sub Item 1"/>
<telerik:RadMenuItem Header="Sub Item 2" Style="{StaticResource RadContextMenuItemStyle}" ItemsSource="{Binding Groups}"
MouseEnter="RadMenuItem_MouseEnter" Loaded="RadMenuItem_Loaded" Name="cont">
<telerik:RadMenuItem.ItemContainerStyle>
<Style TargetType="telerik:RadMenuItem">
<Setter Property="Header" Value="{Binding Name}" />
<Setter Property="IsSeparator" Value="{Binding IsSeparator}" />
<Setter Property="CommandParameter" Value="{Binding Id}"/>
</Style>
</telerik:RadMenuItem.ItemContainerStyle>
</telerik:RadMenuItem>
<telerik:RadMenuItem Header="Item 2" ItemsSource="{Binding Groups}"/>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
in xaml.cs:
private void RadMenuItem_MouseEnter(object sender, MouseEventArgs e)
{
FillMethod();
}
private void FillMethod()
{
if (!f)
{
this.Dispatcher.BeginInvoke(() =>
{
var viewmodel =
(MainPageViewModel)
this.Resources["ViewModel"];
viewmodel.PopupCommand.Execute(null);
});
}
}
private bool f = false;
private void RadMenuItem_Loaded(object sender, RoutedEventArgs e)
{
f = false;
}
in viewmodel:
protected virtual void InvokePopup(object obj)
{
Groups = new List<Group>();
Groups.Add(new Group {Name = "Loading...",Id = "---"});
fillservice.GetGroups();
}
public MainPageViewModel()
{
fillservice = new MockFill();
fillservice.Completeevent += FillContextMenuMethod;
ActionCommand = new DelegateCommand<object>(InvokeAction,CanInvokeAction);
PopupCommand = new DelegateCommand<object>(InvokePopup, CanInvokePopup);
Groups = new List<Group>();
Groups.Add(new Group {Name = "Loading...",Id = "---"});
}
private void FillContextMenuMethod(object sender, GroupsEventArgs e)
{
UIDispatcher.BeginInvoke(() =>
{
Groups = e.Groups.ToList();
});
}
Context menu have a bad behavior, where i change my property group where, submenu is expanding(all arrows had collapsed
for 1-3 seconds and submenu collapsed)