[英]Xceed WPF propertyGrid Custom Collection editor
我是WPF的新手,我使用xceed屬性網格,在我的課程中,我有一個自定義集合編輯器。 按照xceed,我發現我必須實現“ Xceed.Wpf.Toolkit.PropertyGrid.Editors.ITypeEditor”,但是已經實現了,但是在嘗試設置綁定時出現錯誤。 錯誤消息:“雙向綁定需要路徑或XPath”。 下面是c#類,其中定義了屬性:
/// <summary>
/// The expected assembly versions.
/// </summary>
[DescriptionAttribute("The expected assembly versions.")]
[Category("Mandatory")]
[ExpandableObject]
[Editor(typeof(Assembly), typeof(Assembly))]
public Assembly[] ExpectedAssemblyVersions
{
get;
set;
}
/// <summary>
/// To verify assembly and there versions
/// </summary>
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public class Assembly : Xceed.Wpf.Toolkit.PropertyGrid.Editors.ITypeEditor
{
/// <summary>
/// Assembly Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Assembly versions
/// </summary>
public string[] Versions { get; set; }
#region Implementation of ITypeEditor
/// <summary>
///
/// </summary>
/// <param name="propertyItem"></param>
/// <returns></returns>
public FrameworkElement ResolveEditor(PropertyItem propertyItem)
{
TextBox textBox = new TextBox();
var _binding = new Binding(Name);
_binding.Source = propertyItem;
_binding.ValidatesOnExceptions = true;
_binding.ValidatesOnDataErrors = true;
_binding.Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
BindingOperations.SetBinding(textBox, TextBox.TextProperty, _binding);
return textBox;
}
#endregion
}
XAML綁定:
<xctk:PropertyGrid Name="pk" Foreground="{Binding SelectedTheme.FontShade}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontWeight="ExtraBold" Background="{Binding SelectedTheme.DarkShade}" SelectedObject="{Binding SelectedElement,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
“ ResolveEditor”的實現不完整,我需要幫助解決此問題。
您的意思是這樣的嗎:
class Properties
{
private List<Assembly> assemblies = new List<Assembly>();
[DisplayName("ExpectedAssemblyVersions")]
[Description("The expected assembly versions.")]
[Category("Mandatory")]
[Editor(typeof(CollectionEditor), typeof(CollectionEditor))]
public List<Assembly> Assemblies
{
get
{
return assemblies;
}
set
{
assemblies = value;
}
}
}
class Assembly
{
public string Name { get; set; }
public string Version { get; set; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.