All the controls missing in WPF. Over 1 million downloads.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.3 KiB

/***************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2014 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
*************************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using System.Linq;
using System.Collections.ObjectModel;
namespace Xceed.Wpf.Toolkit.LiveExplorer.Samples.PropertyGrid.Views
{
/// <summary>
/// Interaction logic for PropertyGridPropertiesSourceView.xaml
/// </summary>
public partial class PropertyGridPropertiesSourceView : DemoView
{
public PropertyGridPropertiesSourceView()
{
InitializeComponent();
#if !OPEN_SOURCE
var list = new ObservableCollection<object>();
list.Add( new MyData( "string", "First text" ) );
list.Add( new MyData( "Second string", "Second text" ) );
list.Add( new MyData( "Color", Colors.Blue ) );
list.Add( new MyData( "DateTime", System.DateTime.Now ) );
list.Add( new MyData( "TimeSpan", System.TimeSpan.FromMinutes( 120 ) ) );
list.Add( new MyData( "HorizontalAlignment", System.Windows.HorizontalAlignment.Center ) );
list.Add( new MyData( "bool", true ) );
list.Add( new MyData( "decimal", ( decimal )1 ) );
list.Add( new MyData( "int", ( int )2 ) );
list.Add( new MyData( "Second int", ( int )2 ) );
list.Add( new MyData( "short", ( short )3 ) );
list.Add( new MyData( "long", ( long )4 ) );
list.Add( new MyData( "float", ( float )5 ) );
list.Add( new MyData( "byte", ( byte )6 ) );
list.Add( new MyData( "sbyte", ( sbyte )7 ) );
list.Add( new MyData( "uint", ( uint )8 ) );
list.Add( new MyData( "ulong", ( ulong )8 ) );
list.Add( new MyData( "ushort", ( ushort )10 ) );
list.Add( new MyData( "FontFamily", Fonts.SystemFontFamilies.First() ) );
list.Add( new MyData( "FontStyle", FontStyles.Italic ) );
list.Add( new MyData( "FontStretch", FontStretches.ExtraExpanded ) );
// PropertyGrid PropertiesSource property is bound to the DataContext
this.DataContext = list;
#endif
}
#if !OPEN_SOURCE
private void InsertProperty( object sender, RoutedEventArgs e )
{
( ( IList<object> )this.DataContext ).Insert( 0, new MyData( "New string", "new data" ) );
}
private void RemoveProperty( object sender, RoutedEventArgs e )
{
if( _propertyGrid.SelectedProperty != null )
{
( ( IList<object> )this.DataContext ).Remove( _propertyGrid.SelectedProperty );
}
}
private class MyData
{
public MyData( string name, object value )
{
this.MyName = name;
this.MyValue = value;
}
public string MyName { get; set; }
public object MyValue { get; set; }
}
#endif
}
}