返回首页




{S0} {S1}简介
这是我的第二条关于PropertyGrid控制,这为WPF的时间。基础上,我将我以前的文章:" quot;
虽然使用Windows Workflow Foundation 4.0的工作,我意识到,PropertyInspectorView控制确实是一个不折不扣的WPF PropertyGrid控制,包括自定义属性和自定义编辑器的支持。一个PropertyInspectorView与父WorkflowDesigner对象和同级工作流视图对象,这是真正的拖动和放下画布,在这个MSDN的截图所示:{S2}
Workflow Foundation的例子。左:工具箱活动,中东:设计视图,右:物业督察。内部架构
PropertyInspector一般用途的整体方法如下:从网格类派生一个新的控制。该网格将包含真正的UI元素。合并为一个私有的类成员的工作流基金会的WorkflowDesigner对象。 对于设计师的对象,添加相应网格的孩子PropertyInspectorView。虽然它是一个网格暴露出来,真正的类型是ProperyInspector。 通过反思,为进一步利用捕捉一些PropertyInspector方法。 实施SelectedObject和SelectedObjects属性,在定期的PropertyGrid,处理的选择改变PropertyInspector。添加GridSplitter和TextBlock模仿原PropertyGrid的HelpText功能。
下图描绘的Wp​​fPropertyGrid类的内部结构,在前面的行解释:
{S3}
它至少需要调用公共构造和设置SelectedObject或SelectedObjects。刷新时选定的对象已经改变外部控制RefreshPropertyList方法将是有益的的。
设置的HelpVisible属性显示在底部的属性描述,而ToolbarVisible将显示或隐藏上部的工具栏。这些属性有相同的名称为WINFORM的PropertyGrid中,为了保持某种程度的兼容性。
PropertySort财产,接受PropertySort枚举类型相同。它将允许按类别分组的属性,或者在一个扁平化的方式显示。
FontAndColorData财产可用于给页面的控制,因为它内部设置WorkflowDesigner.PropertyInspectorFontAndColorData的属性,但有几个信息在互联网上提供。下面是一些有趣的论坛MSDN页面:基本用法 - Person类
提供的示范项目,将允许您测试的所有WpfropertyGrid功能。有三个类定义中DemoClasses.cs,具有不同的功能,如自定义属性和编辑。这里的第一个也是最简单的声明:
{五}

    public class Person

    {

        public enum Gender { Male, Female }



        #region private fields

        private string[] _Names = new string[3];

        #endregion



        // The following properties are wrapping an array of strings

        #region Public Properties

        [Category("Name")]

        [DisplayName("First Name")]

        public string FirstName

        {

            set { _Names[0] = value; }

            get { return _Names[0]; }

        }



        [Category("Name")]

        [DisplayName("Mid Name")]

        public string MidName

        {

            set { _Names[1] = value; }

            get { return _Names[1]; }

        }



        [Category("Name")]

        [DisplayName("Last Name")]

        public string LastName

        {

            set { _Names[2] = value; }

            get { return _Names[2]; }

        }



        // The following are auto-implemented properties (C# 3.0 and up)

        [Category("Characteristics")]

        [DisplayName("Gender")]

        public Gender PersonGender { get; set; }



        [Category("Characteristics")]

        [DisplayName("Birth Date")]

        public DateTime BirthDate { get; set; }



        [Category("Characteristics")]

        public int Income { get; set; }



        // Other cases of hidden read-only property and formatted property

        [DisplayName("GUID"), ReadOnly(true), Browsable(true)]   

        public string GuidStr

        {

            get { return Guid.ToString(); }

        }



        [Browsable(false)]  // this property will not be displayed

        public System.Guid Guid

        {

            get;

            private set;

        }

        #endregion



        public Person()

        {

            // default values

            for (int i = 0; i < 3; i++)

                _Names[i] = "";

            this.PersonGender = Gender.Male;

            this.Guid = System.Guid.NewGuid();

        }



        public override string ToString()

        {

            return string.Format("{0} {1} {2}", FirstName, 

                MidName, LastName).Trim().Replace("  ", " ");

        }

    }


请注意,该控件将显示刚才的属性,而不是等领域。由于我们使用的是C#3.0或4.0,我们能够避免使用自动实现的属性声明的基础领域,只要是方便。
要显示一个Person对象的属性是安静简单,只需将它分配给控制的SelectedObject属性,如下所示: {C}基本属性
Person类中实现的,你会发现有一些属性,有属性(方括号中的),他们将不会有任何对您的类的行为的效果,但会与属性网格。这些属性是类似的WinForms的PropertyGrid的实施。让我们看看详细。 分类:让您指定为受影响的物业类别组。 A类默认情况下会出现带有灰色背景的属性网格的,你可以看到在第一个屏幕。如果该属性没有属性分类,它属于一个空白的类别组,与在以前的截图的GUID属性。建议总是指定为每个属性的类别。 DisplayName的:当你想显示一个属性的名称,从实际不同,将是有益的。通常情况下,它是用来当你用空格来增加可读性,或缩写名称。只读:设置为true时,将防止从正在编辑的财产;这将是刚刚在属性网格中显示。为了防止被隐藏的只读属性,将必要的,以纪念他们可浏览= TRUE,与GUIDStr财产。可浏览:设置为false时,该属性将不会显示。当你有像第一个例子中的GUID属性,你不想显示在所有的属性,它是有用的。
所有这些属性在System.ComponentModel命名空间声明和自动属性检查确认。可自定义的属性 - 车辆类别
,虽然简单的实现了WpfPropertyGrid公开一类(除可浏览属性设置为false)的所有属性,ICustomProperties接口将允许有条件地揭露一些属性。有做到这一点需要在下面的例子,一些自定义: {中六} {七}{S8}
    public class Vehicle : 

        ICustomTypeDescriptor, INotifyPropertyChanged

    {

        public enum CarType { Sedan, StationWagon, Coupe, 



            Roadster, Van, Pickup, Truck } 

        public enum CarBrand { Acura, Audi, BMW, Citroen, 



            Ford, GMC, Honda, Lexus, Mercedes, Mitsubishi, 

            Nissan, Porshe, Suzuki, Toyota, VW, Volvo }



        #region Private fields

        private CarType _TypeOfCar;

        #endregion



        #region Public Properties

        [Category("Classification")]

        public CarBrand Brand { get; set; }



        [Category("Classification")]

        [DisplayName("Type")]

        public CarType TypeOfCar

        {

            get { return this._TypeOfCar; }

            set {

                this._TypeOfCar = value;

                NotifyPropertyChanged("TypeOfCar");

            }

        }



        [Category("Classification")]

        public string Model { get; set; }



        [Category("Identification")]

        [DisplayName("Manuf.Year")]

        public int Year { get; set; }



        [Category("Identification")]

        [DisplayName("License Plate")]

        public string Plate { get; set; }



        // Will shown only for Pickup and Truck

        [Category("Capacity")]

        [DisplayName("Volume (ft鲁)")]

        public int Volume { get; set; }



        [Category("Capacity")]

        [DisplayName("Payload (kg)")]

        public int Payload { get; set; }



        [Category("Capacity")]

        [DisplayName("Crew cab?")]

        public bool CrewCab { get; set; }

        #endregion



        #region ICustomTypeDescriptor Members

        public AttributeCollection GetAttributes() ...

        public string GetClassName() ...

        public string GetComponentName() ...

        public TypeConverter GetConverter() ...

        public EventDescriptor GetDefaultEvent() ...

        public PropertyDescriptor GetDefaultProperty() ...

        public object GetEditor(Type editorBaseType)

        public EventDescriptorCollection 

            GetEvents(Attribute[] attributes) ...

        public EventDescriptorCollection GetEvents() ...

        public object 

            GetPropertyOwner(PropertyDescriptor pd) ...

        public PropertyDescriptorCollection 

            GetProperties(Attribute[] attributes) ...



        // Method implemented to expose Capacity properties 

        // conditionally, depending on TypeOfCar

        public PropertyDescriptorCollection GetProperties()

        {

            var props = new PropertyDescriptorCollection(null);



            foreach (PropertyDescriptor prop in 

                TypeDescriptor.GetProperties(this, true))

            {

                if (prop.Category=="Capacity" &&

                    (this.TypeOfCar != CarType.Pickup && 

                    this.TypeOfCar != CarType.Truck))

                    continue;

                props.Add(prop);

            }



            return props;

        }

        #endregion



        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;



        private void NotifyPropertyChanged(String info)

        {

            if (PropertyChanged != null)

                PropertyChanged(this, new PropertyChangedEventArgs(info));

        }

        #endregion

    }


注意,最重要的方法需要实施PropertyGrideCE.ICustomProperties接口的是GetProperties()。此方法应返回作为一个数组,取决于一些条件,要公开所有的属性名称。在这个例子中,如果汽车类型的皮卡或卡车,体积,有效载荷和CrewCab属性将被暴露。 自定义编辑器 - Place类免责声明
虽然本文的目的不是去与编辑器定制深,我将展示一个夫妇的两个编辑的例子:扩展和基于对话框的。更多的信息可以发现沿与Workflow Foundation的4个API,或者在我的下一篇文章:)
自定义编辑器是这种控制的最强大的功能。有几个技巧,你可以用它做。默认情况下,控制系统将提供所有的基础类的编辑器:整数,浮点,双等,也可用于字符串和枚举,后者作为一个ComboBox。如果你有一个自定义类作为属性的对象,它会显示字符串表示形式,但只是为ReadOnly,电网的控制,因为不知道如何编辑它。
Place类实现同时显示。尽管主编,它必须从PropertyValueEditor类派生,我们将在详细见后面。
为了指定一个自定义编辑器的属性,它是需要添加一个EditorAttribute属性的财产申报,CountryInfo和图片属性。

    public class Place

    {

        public struct CountryInfo

        {

            public static readonly CountryInfo[] Countries = {

                // African countries

                new CountryInfo(Continent.Africa , "AO", "ANGOLA" ),

                new CountryInfo(Continent.Africa, "CM", "CAMEROON" ),

                // American countries

                new CountryInfo(Continent.America, "MX", "MEXICO" ),

                new CountryInfo(Continent.America, "PE", "PERU" ),

                // Asian countries

                new CountryInfo(Continent.Asia, "JP", "JAPAN" ),

                new CountryInfo(Continent.Asia, "MN", "MONGOLIA" ),

                // European countries

                new CountryInfo(Continent.Europe, "DE", "GERMANY" ),

                new CountryInfo(Continent.Europe, "NL", "NETHERLANDS" ),

                // Oceanian countries

                new CountryInfo(Continent.Oceania, "AU", "AUSTRALIA" ),

                new CountryInfo(Continent.Oceania, "NZ", "NEW ZEALAND" )

            };



            public Continent Contin { get; set; }

            public string Abrev { get; set; }

            public string Name { get; set; }



            public override string ToString()

            {

                return string.Format("{0} ({1})", Name, Abrev);

            }

            public CountryInfo(Continent _continent, 

                string _abrev, string _name) : this()

            {

                this.Contin = _continent;

                this.Abrev = _abrev;

                this.Name = _name;

            }

        }



        #region Private fields

        private string[] _Address = new string[4];

        #endregion



        #region Public properties

        [Category("Address")]

        public string Street

        {

            get { return _Address[0]; }

            set { _Address[0] = value; }

        }

        

        [Category("Address")]

        public string City

        {

            get { return _Address[1]; }

            set { _Address[1] = value; }

        }

        

        [Category("Address")]

        public string Province

        {

            get { return _Address[2]; }

            set { _Address[2] = value; }

        }

        

        [Category("Address")]

        public string Postal

        {

            get { return _Address[3]; }

            set { _Address[3] = value; }

        }



        // Custom editor for the following 2 properties

        [Category("Address")]

        [Editor(typeof(CountryEditor), typeof(PropertyValueEditor))]

        public CountryInfo Country { get; set; }

        

        [Category("Characteristics")]

        [Editor(typeof(PictureEditor), typeof(PropertyValueEditor))]

        public BitmapImage Picture { get; set; }

        

        [Category("Characteristics")]

        public int Floors { get; set; }

        

        [Category("Characteristics")]

        public int CurrentValue { get; set; }

        #endregion



        public Place()

        {

            for (int i = 0; i < _Address.Length; i++)

                _Address[i] = string.Empty;

            this.Country = CountryInfo.Countries[0];

        }

    }


如前所述,有在广场类的自定义编辑器实现的两个例子,第一个,CountryEditor,是一个扩展的编辑器。它要求一个国家有两个组合框:一个大陆,为国家之一,如截图所示。为了简化演示,所需的XAML的DataTemplate是放置在源代码的文件,这是不使平常:
    

    class CountryEditor : ExtendedPropertyValueEditor

    {

        public CountryEditor()

        {

            // Template for normal view

            string template1 = @"...xaml template here...";



            // Template for extended view. Shown when dropdown button is pressed.

            string template2 = @"...xaml template here..."; 



            // Load templates

            using (var sr = new MemoryStream(Encoding.UTF8.GetBytes(template1)))

            {

                this.InlineEditorTemplate = XamlReader.Load(sr) as DataTemplate;

            }

            using (var sr = new MemoryStream(Encoding.UTF8.GetBytes(template2)))

            {

                this.ExtendedEditorTemplate = XamlReader.Load(sr) as DataTemplate;

            }

        }

    }


扩展编辑器,它必须从ExtendedPropertyValueEditor类派生。这将允许属性网格下拉属性数据输入一个自定义控制。
构造函数应该载入模板,正​​常和扩展,从一些XAML的DataTemplate声明。通常这些模板被放置在一个XAML资源文件。
自定义编辑器的第二个例子是PictureEditor,它是从一个扩展编辑器不同,因为它显示了一个新的对话框的下拉按钮被按下时,使这将需要单独实施该窗口。此外,来自不同的基类:DialogPropertyValueEditor。 Sample类的缩写,目的是显示部分:
    class PictureEditor : DialogPropertyValueEditor

    {

        // Window to show the current image and optionally pick a different one

        public class ImagePickerWindow : Window

        {

            // regular window implementation here

        }



        public PictureEditor()

        {

            string template = @"...xmal template here...";



            using (var sr = new MemoryStream(Encoding.UTF8.GetBytes(template)))

            {

                this.InlineEditorTemplate = XamlReader.Load(sr) as DataTemplate;

            }

        }



        // Open the dialog to pick image, when the dropdown button is pressed 

        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)

        {

            ImagePickerWindow window = new ImagePickerWindow(propertyValue.Value as BitmapImage);

            if (window.ShowDialog().Equals(true))

            {

                var ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();

                ModelItem activityItem = ownerActivityConverter.Convert(propertyValue.ParentProperty, 

                    typeof(ModelItem), false, null) as ModelItem;

                using (ModelEditingScope editingScope = activityItem.BeginEdit())

                {

                    propertyValue.Value = window.TheImage; 

                    editingScope.Complete(); // commit the changes

                }

            }

        }

    }

多重选择
虽然单一的选择可以通过SelectedObject属性设置为任何值,多重选择是通过设置SelectedObjects属性。
当选择多个对象,在控制顶部的类型标签将显示单词quot; LT; multiplegt"类型rigth。如果所有选定的对象都是同一类型,类型名称显示(见下面的截图)。如果不是,它是类型quot; Objectquot;
的所有属性,具有相同的类型和所有选定对象的名称所示,即使选定的对象是不是同一类型的。在演示应用,尝试用人员和地点,共享FirstName和LastName属性。 {S0}帮助文本
控制底部的文本框被称为HelpText。它会显示DescriptionAttribute属性(见上面的截图)设置的属性的描述。
当有多个选定的对象,说明将只显示所有选定对象是同一类型的。
HelpText框可以显示或隐藏设置PropertyGrid的HelpVisible属性。 如何使用它
WpfPropertyGrid可以被直接嵌入到您的应用程序。它并不需要在一个单独的DLL编译。包括一些XAML声明,你必须指定正确的命名空间(本地System.Windows.Control),并添加相应的标签到您的WPF窗口或对话框:依赖项属性
由于控制属性都是依赖属性,它们可以被绑定到其他元素的容器对话框或窗口在演示应用程序(简体),如:
<Window x:Class="WpfPropertyGrid_Demo.MainWindow"

   xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   xmlns:sys="clr-namespace:System;assembly=mscorlib"

   xmlns:wpg="clr-namespace:System.Windows.Controls"

   Title="WpfPropertyGrid Demo" mc:Ignorable="d" ResizeMode="CanResizeWithGrip" 

   Width="360" Height="360" MinWidth="360" MinHeight="400">



   <wpg:WpfPropertyGrid x:Name="PropertyGrid1" 

      Margin="20,20,118,21" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 

      HelpVisible="{Binding ElementName=ShowDescrip, Path=IsChecked}" 

      ToolbarVisible="{Binding ElementName=ShowToolbar, Path=IsChecked}"

      PropertySort="{Binding ElementName=ComboSort, Path=SelectedItem}" />



演示应用已建立与Visual Studio 2010。由于WPF属性检查器是一个。NET 4.0中的新功能,这将不会被执行。NET 3.0或3.5编写的应用程序,甚至当他们实施Workflow Foundation的。
使用此控件,你只需要添加到您的项目WpfPropertyGrid.cs的文件。在您的解决方案将需要一些参考: System.ActivitiesSystem.Activities.Core.Presentation System.Activities.Presentation历史 2010年6月14日,第一版。2010年8月31日,第二版。简体实施(感谢Drammy和brannonking)2010年9月13日,主要改进:多种选择,帮助文本框,延长演示。2011年7月12日:第四版。依赖属性,显示/隐藏工具栏和categories.nbsp;

回答

评论会员:Badiboy 时间:2012/01/26
嗨,是我再次抱歉。 {S13}

我没有/一个/多个对象显示在PG和清除属性网格的问题。我写下面的代码:

switch (selObjects.Count)

{

    case 0:

        propertyGrid.SelectedObject = null;

        propertyGrid.SelectedObjects = null;

        break;

    case 1:

        propertyGrid.SelectedObject = selObjects[0];

        propertyGrid.SelectedObjects = null;

        break;

    default:

        propertyGrid.SelectedObject = null;

        propertyGrid.SelectedObjects = selObjects.ToArray();

        break;

}

此代码不就行了:
    propertyGrid.SelectedObjects = null;
堆栈溢出在PG上线的消息:
private static void SelectedObjectsPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)

{

    WpfPropertyGrid pg = source as WpfPropertyGrid;

    pg.CoerceValue(SelectedObjectsProperty);      <<<<<

    ...
(他们要么是空的,或其中之一),独立SelectedObject和SelectedObjects国家。

此代码做什么,我需要(设置SelectedObject为null清除的PG):
switch (selObjects.Count)

{

    case 0:

        propertyGrid.SelectedObject = null;

        break;

    case 1:

        propertyGrid.SelectedObject = selObjects[0];

        break;

    default:

        propertyGrid.SelectedObjects = selObjects.ToArray();

        break;

}
然而,在某些情况下(我不能清楚地赶上他们),PG记得,它已经定义SelectedObjects,试图展示他们的价值观和一个异常,因为这些对象不

我尝试下一个代码:
if (selObjects.Count == 0)

{

    propertyGrid.SelectedObjects = null;

}

else

{

    propertyGrid.SelectedObjects = selObjects.ToArray();

}
但设置SelectedObjects的问题仍然存在。

任何人都可以给正确的使用方法SelectedObject(S)或PG需要一些修复
评论会员:?Badiboy 时间:2012/01/26
。起初,他的工作表示感谢海梅,它的amasing

现在的问题。我班有三个属性,可以通过PropertyGrid的访问。,
例如:
[ReadOnly(false), Browsable(true)]

bool isInput;

[ReadOnly(false), Browsable(???)]

string InputName;

[ReadOnly(false), Browsable(???)]

string OutputName;

根据"isInput"价值,我需要表现出"InputName"或"OutputName"。是否有可能在运行时改变属性的知名度,这取决于什么?(我谈至少手动开关在代码中的知名度,没有必要做值的变化,它会自动)。
在此先感谢
评论会员:。海梅奥利瓦雷斯 时间:2012/01/26
您好BadiBoy,
这种情况已经描述了在汽车的例子,使用的TypeOfCar属性来确定属性来显示。
属性是不是一个好的选择,它们会影响一类,没有一个实例。此外,属性大多是静态的(除非你做一些肮脏的把戏)。
最好的问候,
海梅
评论会员:。Badiboy 时间:2012/01/26
我的耻辱! 有点复杂(ICustomTypeDescriptor重新定义),但允许的PropertyGrid留普及。
它似乎有用的添加ICustomTypeDescriptor重新定义PropertyGrid的包"CustomType"类。
和自定义类型的用户,只需将继承"CustomType"和扩展所需的功能(属性字段和GetProperties()方法)。
我计划实施以这种方式设置的自定义属性。 {S13}

谢谢你,海梅!
阿列克谢
评论会员:RJStalb 时间:2012/01/26
!美仑美奂的实施 - 路要走
评论会员:FlankeRiot 时间:2012/01/26


有没有办法添加自定义排序的行吗?

比如人,我想能够显示姓氏总是第一个在顶部,,但它总是按字母顺序显示所有领域(姓氏的名字下,例如)

提前
感谢
评论会员:海梅奥利瓦雷斯 时间:2012/01/26
嗨,
我没有尝试过这种控制,但你可以这样做:
更改[显示名称]属性包含这被认为是比字母的符号,以点开始,所以你可以有以下的显示名称:
... ...名
..半山名
姓氏
如果它的工作原理,尝试替换为空字符(ASCII零)这样的非打印字符:\ 0
最好的问候,
海梅
评论会员:。aliascodeproject 时间:2012/01/26
你知道如何我可以改变的代码中的标签和值列的宽度,例如
我想标签列,40%和PropertyGrid的总宽度值列中的60%...
评论会员:海梅奥利瓦雷斯 时间:2012/01/26
这是有点复杂的东西,你可以遍历所有的可视化树看网格控制包含的属性。然后,更改第一列的宽度。
最好的问候,
海梅
评论会员:。aliascodeproject 时间:2012/01/26
我做没有线索该怎么做,以及如何找到网格...我看着窥探(WPF间谍),看到每一类都有其自己的网格。这将会使问题复杂化,我猜。

但你如何确定你需要的网格('S)?要检查哪些属性?

我迷路了..
评论会员:乔Sonderegger 时间:2012/01/26
伟大的代码,但我有两个问题:
1。它不显示在PropertyGrid类。 (即使ExpandableObjectConverter
2。当属性网格在网格嵌入式外部电网修改
评论会员:。pvkekem 时间:2012/01/26
高海梅,

我要显示在PropertyGrid顶部的另一个类名。类名本身是有些过于技术为我们的用户,但我不能改变它。

我想添加一个属性类,如:
[DisplayName("My Displayname")]

public class MyTechnicalClass
但是,这并不工作...

你对我有任何的建议吗?如果不这样做,只是隐藏类名是一个选项,但我不知道该怎么做... ...

非常感谢您的时间!

的问候,

彼得
评论会员:海梅奥利瓦雷斯 时间:2012/01/26
嗨彼得,
很抱歉迟了回应。这里是一个肮脏的把戏:
请以下领域的公众:

私人耻骨TextBlock的SelectionTypeLabel

和手动更改其内容:

myPropGrid.SelectionTypeLabel.Text ="我的DisplayName";
最好的问候,
海梅
评论会员:。pvkekem 时间:2012/01/26
高海梅,

谢谢你的回答。
我想知道我应该加入这一行,因为PropertyGrid类是一个内部。NET类,我不能使用一个基类或东西... ...

能否请您帮我出这个?

再次感谢!

的问候,
彼得
评论会员:pvkekem 时间:2012/01/26
高海梅,

我也有今天再看看我的代码,并通过检查该元素的标签:

this.mlblSelectionType = inspectorType.GetMethod("get_SelectionTypeLabel",

    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |

    BindingFlags.DeclaredOnly).Invoke(inspector, new object[0]) as TextBlock;

现在我可以很容易地设置标签。

非常感谢你的回答!

的问候,

彼得
:m5168 |
评论会员:游客 时间:2012/01/26
。感谢这个伟大的控制问:我怎么改变背景颜色和字体颜色控制
?海梅奥利瓦雷斯
评论会员:游客 时间:2012/01/26
您好,这是一个非常模糊的话题的PropertyInspector。在这篇文章中我提到,讨论了它的链接:imgsrc=http://www.orcode.com/upimg/2012_01_26_04_28_03_3.png[]最好的问候,海梅
。Dmitiry
评论会员:游客 时间:2012/01/26
!您好伟大的工作!但有一个问题,如果我使用的FlagsAttribute枚举,然后不选定的场可视化是不正确的。imgsrc=http://www.orcode.com/upimg/2012_01_26_04_28_05_5.png有谁知道它是微软的bug吗?是否有可能以某种方式解决它?预先感谢。我道歉,我的英语。梅德
。海梅奥利瓦雷斯
评论会员:游客 时间:2012/01/26
您好Dimtry,我不认为标准的enum编辑器支持的标志。您必须编写您自己的编辑器(一些kindofComboBox或ListBox与复选框)最好的问候,海梅
。Dmitiry
评论会员:游客 时间:2012/01/26
感谢。也许你说得对,但imgsrc=http://www.orcode.com/upimg/2012_01_26_04_28_06_6.png此属性是正确的。你可以建议如何做到这一点的ComboBox,但不包含ComboBox的下拉菜单中。我不喜欢像imgsrc=http://www.orcode.com/upimg/2012_01_26_04_28_07_7.png
。海梅奥利瓦雷斯
评论会员:游客 时间:2012/01/26
也许你可以检查为WinForms类似的实现:[imgsrc=http://www.orcode.com/upimg/2012_01_26_04_28_07_8.png最好的问候,海梅
塞巴斯蒂安Edelmeier
评论会员:游客 时间:2012/01/26
高海梅,感谢这个整洁的解决方案-它是真正聪明的和可扩展性是可以罚款。我已经尝试了一些步骤,但我不太神交。首先,我想为一个GUID属性的行编辑器。与平原之一的TextBlock和一个按钮,没有弹出窗口,没有扩展编辑器模板。在按钮的Click,我想产生一个新的GUID。这里是我的代码至今:codeprelang="c#"spanclass="code-keyword"public/spanspanclass="code-keyword"class/spanGuidEditor:PropertyValueEditor{spanclass="code-keyword"public/spanGuidEditor(){DataTemplatedt=Application.Current.FindResource(spanclass="code-string""/spanspanclass="code-string"guidEditorTemplate"/span)spanclass="code-keyword"as/spanDataTemplate;spanclass="code-keyword"if/span(dt!=spanclass="code-keyword"null/span){spanclass="code-keyword"this/span.InlineEditorTemplate=dt;}}}/pre/codecodeprelang="HTML"spanclass="code-keyword"</spanspanclass="code-leadattribute"ResourceDictionary/spanspanclass="code-attribute"xmlns/spanspanclass="code-keyword"="/spanspanclass="code-keyword"http://schemas.microsoft.com/winfx/2006/xaml/presentation"/spanspanclass="code-attribute"xmlns:x/spanspanclass="code-keyword"="/spanspanclass="code-keyword"http://schemas.microsoft.com/winfx/2006/xaml"/spanspanclass="code-attribute"/spanspanclass="code-attribute"<DataTemplate/spanspanclass="code-attribute"x:Key/spanspanclass="code-keyword"="/spanspanclass="code-keyword"guidEditorTemplate"/spanspanclass="code-attribute"/spanspanclass="code-attribute"<DockPanel/spanspanclass="code-attribute"<TextBox/spanspanclass="code-attribute"x:Name/spanspanclass="code-keyword"="/spanspanclass="code-keyword"lblCurrentGuid"/spanspanclass="code-attribute"x:Uid/spanspanclass="code-keyword"="/spanspanclass="code-keyword"lblCurrentGuid"/spanspanclass="code-attribute"Text/spanspanclass="code-keyword"="/spanspanclass="code-keyword"{BindingPath=Value}"/spanspanclass="code-attribute"IsReadOnly/spanspanclass="code-keyword"="/spanspanclass="code-keyword"True"/spanspanclass="code-attribute"DockPanel.Dock/spanspanclass="code-keyword"="/spanspanclass="code-keyword"Left"/spanspanclass="code-attribute"/spanspanclass="code-keyword"<//spanspanclass="code-leadattribute"TextBox/spanspanclass="code-attribute"<Button/spanspanclass="code-attribute"x:Name/span=spanclass="code-keyword""/spanspanclass="code-keyword"btnNewGuid"/spanspanclass="code-attribute"x:Uid/span=spanclass="code-keyword""/spanspanclass="code-keyword"btnNewGuid"/spanspanclass="code-attribute"ToolTip/span=spanclass="code-keyword""/spanspanclass="code-keyword"generatenewGuid"/spanspanclass="code-attribute"Margin/span=spanclass="code-keyword""/spanspanclass="code-keyword"5,0,0,0"/spanspanclass="code-attribute"Width/span=spanclass="code-keyword""/spanspanclass="code-keyword"20"/spanspanclass="code-attribute"Height/span=spanclass="code-keyword""/spanspanclass="code-keyword"20"/spanspanclass="code-attribute"DockPanel.Dock/span=spanclass="code-keyword""/spanspanclass="code-keyword"Right"/spanspanclass="code-attribute"/spanspanclass="code-attribute"<Image/spanspanclass="code-attribute"Source/span=spanclass="code-keyword""/spanspanclass="code-keyword"Images/reload.png"/spanspanclass="code-attribute"</spanspanclass="code-keyword"//spanspanclass="code-attribute"Image/spanspanclass="code-attribute"</spanspanclass="code-keyword"//spanspanclass="code-attribute"Button/spanspanclass="code-attribute"</spanspanclass="code-keyword"//spanspanclass="code-attribute"DockPanel/spanspanclass="code-attribute"</spanspanclass="code-keyword"//spanspanclass="code-attribute"DataTemplate/spanspanclass="code-attribute"</spanspanclass="code-keyword"//spanspanclass="code-attribute"ResourceDictionary/span/pre/code显然,在使用模板时,DataContext是设置为PropertyValue实例editor.How修改我可以处理的按一下按钮,并使用此事件来设置对象呢?使用命令绑定将一个想法,并给予PropertyValue为CommandParameter...不过,如何界定该命令?据我了解正确使用对话框窗口是比较容易的,因为PropertyValue对象ShowDialog方法的参数可以设置。是否有任何类似的方式设置其他的编辑器基类的PropertyValue吗?我还没有发现任何对象浏览器中...提前感谢了很多SEBI
海梅奥利瓦雷斯
评论会员:游客 时间:2012/01/26
您好塞比,你能后我一个完整的示例应用程序?你可以在这里找到jaimeolivares.com我的电子邮件地址最好的问候,海梅
。emil_yotov
评论会员:游客 时间:2012/01/26
您好,如何加载字体列表或Listlt;对象。感谢
塞巴斯蒂安Edelmeier
评论会员:游客 时间:2012/01/26
大文章,极大的控制提取!感谢您的工作,海梅