Working with Lightswitch, Silverlight & custom controls

Viewed 2381

I have a screen with some data. Inside the screen I have two custom controls (on the left and right side).

What I need to do is the following:

Bind some data from a database to some Controls in the first Custom control. (fill a list, combobox etc, not so much the problem)

The user then can select an entry in the list, press a button -> the second CustomControl should now be made visible; request some data from the DB, based on the selection and dynamicly create and show a Chart.

So I know how to build the chart and build the Controls. But how can I access the Data from the screen through code and access another CustomControl from within the first CustomControl?

Edit:

Things I found out.

  1. Access control from screen

    this.FindControl("yourControl");

  2. Do something with the control:

    this.FindControl("yourControl").ControlAvailable += ( (o,e) => { YourControlType myControl = e.Control as YourControlType; });

  3. Access screen data

        IContentItem dataContext = this.DataContext as IContentItem;
        IScreenObject screen = dataContext.Screen;
    
        IScreenProperty prop = screen.Details.Properties["yourProperty"];
    
        VisualCollection<yourProperty> items = prop.Value as  VisualCollection<yourProperty>;
    
  4. Show new screen

    Application.Current.Details.Dispatcher.BeginInvoke(() => Application.Current.ShowGraphScreen(reportItem.BlockID));

Maybe this will help someone.

1 Answers
Related