public ContextMenu()
{
DefaultStyleKey = typeof(ContextMenu);
_openingStoryboard = new List<Storyboard>();
if (null == Application.Current.RootVisual)
{
// Temporarily hook LayoutUpdated to find out when Application.Current.RootVisual gets set.
LayoutUpdated += OnLayoutUpdated;
}
else
{
// We've already missed the LayoutUpdated event, so we are safe to call InitializeRootVisual() to compensate.
InitializeRootVisual();
}
}