wpftoolkit
wpftoolkit copied to clipboard
Can't view collection content in ReadOnly PropertyGrid
BoucherS[CodePlex]
Based on discussion
https://wpftoolkit.codeplex.com/discussions/660443
BoucherS[CodePlex]
Hi,
This will be fixed in v3.4.
―――― Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF
I am using 3.5 and the PropertyGrid still does not show collection content. I tried string[], List<string>, IReadOnlyList<string>, and ReadOnlyCollection<string> — none worked.
This is probably a duplicate of #724 and possibly #599 — though either way, the problem does not appear to be addressed in current versions of the Toolkit.
Hi,
This actually works in Toolkit v3.4 and up, as stated in the release notes : https://xceed.com/release-notes/#toolkit-wpf-3.4.17280.14430
When the PropertyGrid is ReadOnly and contains any property types mentionned, the Collection button can be pressed to view the property content.
ex : <xctk:PropertyGrid SelectedObject="{Binding}" IsReadOnly="True"/>
public partial class MainWindow : Window { public MainWindow() { InitializeComponent();
this.DataContext = new MyObject()
{
FirstName = "Bob",
Data = new string[] { "A", "B", "C" },
Names = new List<string>() { "One", "Two", "Three" },
ROCol = new ReadOnlyCollection<string>( new List<string>() { "Mike", "Kelly", "Gina" } )
};
}
}
public class MyObject { public string FirstName { get; set; }
public string[] Data
{
get;
set;
}
public List<string> Names
{
get;
set;
}
public ReadOnlyCollection<string> ROCol
{
get;
set;
}
}
Retesting this with toolkit 4.0.1, and I see that collection content does show in read-only PropertyGrids, but only as long as the property has a public setter:

But if the property does not have a public setter, there is no way to view collection content:

I am not sure why a public setter is required to view a read-only collection in a read-only PropertyGrid.
public class IHaveOnlyGetters {
public string[] Data { get; } = new string[] { "A", "B", "C" };
public List<string> Names { get; } = new List<string>() { "One", "Two", "Three" };
public ReadOnlyCollection<string> ROCol { get; } = new ReadOnlyCollection<string>(new List<string>() { "Mike", "Kelly", "Gina" });
}
public class IHaveSettersToo {
public string[] Data { get; set; } = new string[] { "A", "B", "C" };
public List<string> Names { get; set; } = new List<string>() { "One", "Two", "Three" };
public ReadOnlyCollection<string> ROCol { get; set; } = new ReadOnlyCollection<string>(new List<string>() { "Mike", "Kelly", "Gina" });
}
Hi, Good catch. Thank you for reporting this. It will be fixed in the next release v4.1.
@XceedBoucherS I retested with 4.6.97 and 5.0.103 and the issue described in https://github.com/xceedsoftware/wpftoolkit/issues/1090#issuecomment-705888339 is still reproducible.
Hi @mstefarov , What version are you refering to ? On GitHub, the latest version of Wpf Toolkit is v4.5. Where did you get thos v4.6 and v5.0 versions ? Thank you
Sorry, I accidentally tested with dotnetprojects/WpfExtendedToolkit fork instead of the official builds.
Just retested with 4.5.1 and read-only collections now expand correctly, with or without a public setter. Thank you for fixing this!
unsubscribe.
At 2023-09-19 20:28:24, "XceedBoucherS" @.***> wrote:
Closed #1090 as completed.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>