/// <summary> /// Checks whether columns can be restored. /// </summary> /// <param name="subject">Target ManagementList.</param> /// <param name="callback">RetryActionAfterLoaded callback method.</param> /// <returns>True iff columns restorable.</returns> /// <exception cref="InvalidOperationException"> /// ManagementList.AutoGenerateColumns not supported. /// </exception> private static bool VerifyColumnsRestorable(ManagementList subject, RetryActionCallback <ManagementList> callback) { if (WpfHelp.RetryActionAfterLoaded <ManagementList>(subject, callback, subject)) { return(false); } if (WpfHelp.RetryActionAfterLoaded <ManagementList>(subject.List, callback, subject)) { return(false); } if (subject.List == null) { return(false); } // Columns are not savable/restorable if AutoGenerateColumns is true. if (subject.List.AutoGenerateColumns) { throw new InvalidOperationException("View Manager is not supported when AutoGenerateColumns is set."); } return(true); }
private static bool VerifyColumnsSavable(ManagementList subject, RetryActionCallback <ManagementList> callback) { if (!VerifyColumnsRestorable(subject, callback)) { return(false); } if (subject.List.InnerGrid == null) { return(false); } return(true); }
/// <summary> /// Calls a method when the Loaded event is fired on a FrameworkElement. /// </summary> /// <typeparam name="T">The type of the parameter to pass to the callback method.</typeparam> /// <param name="element">The element whose Loaded state we are interested in.</param> /// <param name="callback">The method we will call if element.IsLoaded is false.</param> /// <param name="parameter">The parameter to pass to the callback method.</param> /// <returns> /// Returns true if the element is not loaded and the callback will be called /// when the element is loaded, false otherwise. /// </returns> public static bool RetryActionAfterLoaded <T>(FrameworkElement element, RetryActionCallback <T> callback, T parameter) { if (element.IsLoaded) { return(false); } RetryActionAfterLoadedDataQueue data; if (!retryActionData.TryGetValue(element, out data)) { data = new RetryActionAfterLoadedDataQueue(); retryActionData.Add(element, data); } data.Enqueue(callback, parameter); element.Loaded += new RoutedEventHandler(Element_Loaded); element.ApplyTemplate(); return(true); }
private static bool VerifyRulesSavableAndRestorable(ManagementList subject, RetryActionCallback <ManagementList> callback) { if (WpfHelp.RetryActionAfterLoaded <ManagementList>(subject, callback, subject)) { return(false); } if (subject.AddFilterRulePicker == null) { return(false); } if (subject.FilterRulePanel == null) { return(false); } if (subject.SearchBox == null) { return(false); } return(true); }