This is a migrated thread and some comments may be shown as answers.

Toolkit DataForm with TransitionControl 2011 Q3

1 Answer 34 Views
TransitionControl
This is a migrated thread and some comments may be shown as answers.
Peter Avritch
Top achievements
Rank 1
Peter Avritch asked on 22 Dec 2011, 08:45 PM
Hello,
We use a TransitionControl as part of an image picker user control which all lives inside an SL4 toolkit DataForm control in combination with RIA Services. This has all worked fine for the last 18 months or so through all Telerik updates.

However, starting with 2011 Q3 (and also for Q3 SP1), the DataForm was throwing an exception when clicking save on any of our 15+ dialogs hosting this image picker.

I tracked the problem down to where the DataForm was enumerating the bindable properties of the RadTransitionControl. Apparently a recent change to this control resulted in a null value being inserted into the List<DependencyProperty>, which ultimately caused a managed runtime error up the chain.

Since the SL4 Toolkit includes source, I made a simple change to ensure null values do not get added to the List, and now all is good again.

I am not held up on this since I have simply included my own compiled copy of this DLL into my project; however, I thought you would like to be aware of this conflict so you might address it in your next release.

My own code base is too big to include as a sample, but I would believe you could reproduce this simply by including a transition control inside a DataForm edit template and clicking save to trigger the DataForm's validation logic.



System.Windows.Controls.Data.DataForm.Toolkit\DataForm\ValidationUtil.cs

       /// <summary>
        /// Gets the list of dependency properties for the given element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The list of dependency properties.</returns>
        public static List<DependencyProperty> GetDependencyPropertiesForElement(FrameworkElement element)
        {
            List<DependencyProperty> dependencyProperties = new List<DependencyProperty>();

            if (element == null)
            {
                return dependencyProperties;
            }

            bool isBlocklisted =
                element is Panel || element is Button || element is Image || element is ScrollViewer || element is TextBlock ||
                element is Border || element is Shape || element is ContentPresenter || element is RangeBase;

            if (!isBlocklisted)
            {
                FieldInfo[] fields = element.GetType().GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);

                if (fields != null)
                {
                    foreach (FieldInfo field in fields)
                    {
                        if (field.FieldType == typeof(DependencyProperty))
                        {
#if true // this is the fix
       // make sure the list doen't have any null records
                            var dp = (DependencyProperty)field.GetValue(null);
                            if (dp != null)
                                dependencyProperties.Add(dp);
#else // original way
    // the error is that with the 2011 Q3 RadTransitionControl, this
    // causes a null to end up in the list, which then throws a
    // managed runtime error 4004 in the caller.
                                dependencyProperties.Add((DependencyProperty)field.GetValue(null));
#endif
                        }
                    }
                }
            }

            return dependencyProperties;
        }

Cheers,
Peter

1 Answer, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 27 Dec 2011, 03:14 PM
Hi,

Thank you for the feedback. We have found out that there is one unused dependency property declaration for the bool IsTransitionPlaying which was replaced with its negative IsTransitionIdle. The second is more commonly used as one can bind IsEnabled to IsTransitionIdle in cases where some UI should not be available while the transitions are on. The leftover however seems to break the code you refer as the static field never gets a value and remains null. We will fix that ASAP.

Kind regards,
Pana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
TransitionControl
Asked by
Peter Avritch
Top achievements
Rank 1
Answers by
Pana
Telerik team
Share this question
or