Custom user-made modal collection editor windows with Propert Grid?

Firstly - congratulations on a great control!

However, I've stumbled across a potential deal breaker. :(

I have some quite complex data structures that I need to work with. My prototype was written in vb + winforms, but my production app is in wpf mvvm. It basically allows you to set up game controls for games. Below is an example of it in action - you'll see it opens a custom modal window (that I designed) which returns a List(of T) where T is another class (quite complex data structures - thus the need for custom collection editor windows). The PropertyGrid's built-in Collection Editor functionality is not going to be sufficient in itself to do what I need. The video of it in action:

https://youtu.be/u8weURUMjnE

So here are the relevant bits of the data classes:

Public Class Game


Public Property GameControlFunctions As New List(Of GameControlFunction)
End Class

Public Class GameControlFunction
Public Property ID As ObjectId = ObjectId.NewObjectId
Public Property Control As stig.Control
Public Property GameMode As GameMode
Public Property GameFunction As String = Nothing
End Class


And here is the associated UITypeEditor Class and Form:

Public Class GameControlFunctionsUIEditor

Inherits UITypeEditor


Public Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle
If context Is Nothing OrElse context.Instance Is Nothing Then Return MyBase.GetEditStyle(context)
Return UITypeEditorEditStyle.Modal
End Function


Public Overrides Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider,
ByVal value As Object) As Object


Dim editorService As IWindowsFormsEditorService
If context Is Nothing OrElse context.Instance Is Nothing OrElse provider Is Nothing Then Return value
editorService = CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService)


Dim game As Game = DirectCast(context.Instance, Game)
Dim editorForm As New GameControlFunctionsForm(value, game)


If editorService.ShowDialog(editorForm) = Windows.Forms.DialogResult.OK Then


Return New List(Of GameControlFunction)(editorForm.GameControlFunctionsList)


End If


Return value


End Function


End Class




Public Class GameControlFunctionsForm


' This holds the GameControlFunctions List that ultimately updates the GameCOntrolFunctions in Game
Public GameControlFunctionsList As New List(Of GameControlFunction)


' All Other Form logic code here


End Class



I really would like to use this control, but really do need to be able to use custom collection editors. Is this possible at all?



10 Replies

GT Gokul Thanudhas Syncfusion Team September 27, 2022 04:16 PM UTC

Hi Steve,


Sorry for the delay in getting back to you.


Could you please share the following details?
  1. Please share the simple sample by which you are returning the collection to create the collection editor in propertyGrid
  2. Please share the video, the given video link is not able to access

Regards,

Gokul T.



ST Steve September 27, 2022 07:32 PM UTC

Hi Gokul,

The video is on youtube and is publicly available, so I don't understand why you can't see it. I have just tested it and it works just fine for me without being logged into youtube. 


On (1) - I'm not sure what code you are asking for as I am asking about how you would hypothetically achieve something in this control based on the prototype I am showing in the video which used WinForm PropertyGrid. My prototype is not easy to share, unfortunately as it is not a stand alone application but dependant upon other 3rd party applications that I cannot distribute. 


thanks

Steve



GT Gokul Thanudhas Syncfusion Team September 28, 2022 10:05 AM UTC

Hi Steve,


We are able to access your video from our phone, we checked the video.


Is this the default collection editor from WF PropertyGrid? or have your customized this editor?



Do you want to show a custom WPF window (application side window) to appear for the collection editor instead of the default collection editor(SfPropertyGrid)?


Regards,

Gokul T.



ST Steve September 28, 2022 06:08 PM UTC

Hi Gokul. Glad you could view the video. If it's a region lock thing - couldn't you VPN on a desktop to access youtube?


As per my original post - the video is showing you an example of what functionality I am trying to achieve with SfPropertyGrid. The example is made with the standard Winforms PropertyGrid control and code included in the original post. 

What I am asking is how I achieve similar with SfPropertyGrid. The Clooection Editor functions of SfPropertyGrid can't achieve this. I need the ability to launch custom modal windows and return values to the property as per my example. 

Hope this makes sense and you can help



ST Steve September 28, 2022 06:10 PM UTC

If it's still hard to understand, I can knock together a small VS Solution to show you what this would look like as a winforms project with the question "how would you achieve the same with WPF sfPropertyGrid?"



BA BagavathiPerumal Apranandham Syncfusion Team September 29, 2022 01:34 PM UTC

Hi Steve,


We have prepared the sample based on your requirement using a custom Editor. Please refer to the attached sample and video for your reference.


If we misunderstood your query, please provide more information about your query. So that we can prompt a better solution.


Regards,
Bagavathi Perumal A


Attachment: PropertyGrid_WPF_c87fec1d.zip


ST Steve September 29, 2022 07:56 PM UTC

Hi - thanks for this - I've had a quick look as a bit pushed for time at the moment and very busy this weekend. This is a good start and provides a good framework for making this work, although I note it doesn't pass the data objects (List<Author>) from the modal window back to the PropertyGrid Object Property (i.e Employee.CustomCollection). 

However - it does give me something to work on. I'm, guessing  Employee.CustomCollection should really be 

Public Property CustomCollection As List(Of Author) = New List(Of Author)

As I say, I super busy this weekend, but will take a look when I can find some time with work on top, unless you know how to easily modify your code to achieve the data property update. Thanks for giving me a start, though




GT Gokul Thanudhas Syncfusion Team October 4, 2022 09:30 AM UTC

Hi Steve,


We have created the sample based on your requirement. Please refer the attached sample for your reference.


Regards,

Gokul T.


Attachment: PropertyGridCollection.Editor_9c55e689.zip


ST Steve October 5, 2022 08:19 PM UTC

Gokul - you're an absolute ⭐

Thanks, man!

This is awesome.



GT Gokul Thanudhas Syncfusion Team October 7, 2022 04:50 AM UTC

Hi Steve,


We are glad to know that your issue has been fixed. Please let us know if you need any other assistance. We are happy to assist you.



Regards,

Gokul T.



Loader.
Up arrow icon