Example #1
0
        /// <summary>
        /// Called when a Read-Only dependency property is changed
        /// </summary>
        /// <param name="depObj">The dependency object</param>
        /// <param name="e">The event arguments</param>
        private static void OnReadOnlyPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            Frame frame = depObj as Frame;

            if (frame != null && !frame.AreHandlersSuspended())
            {
                frame.SetValueNoCallback(e.Property, e.OldValue);
                throw new InvalidOperationException(
                          string.Format(
                              CultureInfo.InvariantCulture,
                              Resource.UnderlyingPropertyIsReadOnly,
                              e.Property.ToString()));
            }
        }
Example #2
0
        private static void CacheSizePropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            Frame frame = (Frame)depObj;

            if (!frame.AreHandlersSuspended())
            {
                int newCacheSize = (int)e.NewValue;
                if (newCacheSize < 0)
                {
                    frame.SetValueNoCallback(CacheSizeProperty, e.OldValue);
                    throw new InvalidOperationException(
                              string.Format(CultureInfo.InvariantCulture,
                                            Resource.Frame_CacheSizeMustBeGreaterThanOrEqualToZero,
                                            "CacheSize"));
                }

                if (frame._navigationService != null && frame._navigationService.Cache != null)
                {
                    frame._navigationService.Cache.ChangeCacheSize(newCacheSize);
                }
            }
        }