Question

I've got standard CreateNewEntity screen. Entity can contain list of entities of some other type. By default there is an add button that opens modal window when user wants to add another entity into collection. However, default modal window was lacking some of the needed functionality so I've done a bit of research. Turns out that default modal screens cannot be modified. So, I found a nice custom modal window helper class. The problem is that I can't seem to be able to access modal window fields in order to enforce needed logic. There are two dropdown lists that are associated. Change in one will result in limiting the other dropdown list options. I'm stuck at this particular part:

var proxy = this.FindControl("DodavanjeParcele");

        proxy.ControlAvailable += (s, e) =>
        {
            var ctrl = e.Control as System.Windows.Controls.Control;
            //how to obtain access to ctrl fields?
        };

"DodavanjeParcele" is custom modal window. Before this, modal window is instantiated and initialized. It pops up after button click and functions as expected. The only thing missing are above-mentioned rules. I need to set change event handlers for modal window fields in order to define rules. As seen above I tried to cast IProxy as a standard Windows control. This is where I got stuck. I can't seem to find a way to access control fields and set event handlers. Any thoughts?

Was it helpful?

Solution

If I understand you correctly, I'm not sure why you need to search through controls or cast anything.

Control1 is an entity which creates an AutoComplete Box (dropdown list). That selection is copied into a local property in the Control1_Changed method. That property is used as a parameter in a filter query to create Control2.

Control1 Control2

C#:

private void Control1_Changed()
{
    this.MyLocalProperty = this.Control1.SelectedItem;
}

VB.NET:

Private Sub Control1_Changed()
    Me.MyLocalProperty = Me.Control1.SelectedItem
End Sub

Just make sure you have Auto Execute Query checked in Control2's Properties and the second control should update and filter when Control1 changes the query parameter.

Auto Execute

The code in my screen shots all takes place inside of Yann's Modal Helper so there is nothing special you need to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top