Beispiel #1
0
		// ----------------------------------------------------------------------
		public SettingListBox()
		{
			if ( DesignerProperties.GetIsInDesignMode( this ) )
			{
				return;
			}
			FrameworkElementSettings listBoxSettings = new FrameworkElementSettings( this );
			listBoxSettings.Settings.Add( new DependencyPropertySetting( this, SelectedIndexProperty ) );
		} // SettingListBox
Beispiel #2
0
		} // WindowClosing

		// ----------------------------------------------------------------------
		private static void OnFrameworkElementSettingsChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e )
		{
			FrameworkElement frameworkElement = dependencyObject as FrameworkElement;
			if ( frameworkElement == null )
			{
				Debug.WriteLine( "FrameworkElementSettings: invalid framework element" );
				return;
			}

			if ( frameworkElement.GetValue( DependencyPropertySetting.ApplicationSettingsProperty ) != null )
			{
				return; // framework-element contains already an application setting
			}

			string settingsKey = e.NewValue as string;
			if ( string.IsNullOrEmpty( settingsKey ) )
			{
				Debug.WriteLine( "FrameworkElementSettings: missing framework element settings key" );
				return;
			}

			// create and attach the application settings to the framework-element
			FrameworkElementSettings frameworkElementSettings = new FrameworkElementSettings( frameworkElement, settingsKey );
			frameworkElement.SetValue( DependencyPropertySetting.ApplicationSettingsProperty, frameworkElementSettings );
		} // OnFrameworkElementSettingsChanged