wpftoolkit icon indicating copy to clipboard operation
wpftoolkit copied to clipboard

Can't view collection content in ReadOnly PropertyGrid

Open xceedsoftware opened this issue 8 years ago • 6 comments

BoucherS[CodePlex]
Based on discussion https://wpftoolkit.codeplex.com/discussions/660443

xceedsoftware avatar Jul 13 '17 12:07 xceedsoftware

BoucherS[CodePlex]
Hi,

This will be fixed in v3.4.

―――― Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF

xceedsoftware avatar Jul 13 '17 12:07 xceedsoftware

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.

mstefarov avatar Sep 18 '18 21:09 mstefarov

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.

mstefarov avatar Sep 18 '18 21:09 mstefarov

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;
}

}

XceedBoucherS avatar Sep 20 '18 14:09 XceedBoucherS

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:

2020-10-08_165400 WpfApp1

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

2020-10-08_165314 WpfApp1

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" });
    }

mstefarov avatar Oct 08 '20 23:10 mstefarov

Hi, Good catch. Thank you for reporting this. It will be fixed in the next release v4.1.

XceedBoucherS avatar Oct 14 '20 19:10 XceedBoucherS

@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.

mstefarov avatar Mar 24 '23 19:03 mstefarov

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

XceedBoucherS avatar Mar 24 '23 20:03 XceedBoucherS

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!

mstefarov avatar Sep 18 '23 22:09 mstefarov

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: @.***>

ben-jobs avatar Sep 22 '23 03:09 ben-jobs