1
 I have control like this

<UserControl x:Class="VideoControl.VideoControl" Loaded="getProperty"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
</UserControl>

And i have method like this

private void getProperty(object sender, RoutedEventArgs e) {
  var objContext = (IContentItem)this.DataContext;
  var Scrn = (Microsoft.LightSwitch.Client.IScreenObject)objContext.Screen;
  var anonObject = Scrn.Details.Properties["VidContentItemRessourcesItem"].Value;

    string result= anonObject.GetType().GetProperty("AssetPubLocator").GetValue(anonObject, null).ToString();

}

but when i run this, object result is null becouse predefined Loaded silverlight function is called before lightswitch screen is loaded, when i call method get property on button click result isnt null becouse lightswitch screen is loaded. So my question is how to call this method after screen is loaded in some pritty way ( no button click).

1 Answers1

0

Ok i solved it like this

 // My control property
public MyControlType MyControl;

    partial void MyEntity_Loaded(bool succeeded) {

      this.SetDisplayNameFromEntity(this.MyEntity);
      // Open in new Thread
      Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() => {
        this.FindControl("VideoControler").ControlAvailable += (s, e) => {
          // Loading Control
          MyControl = (e.Control as MyControlNamespace.MyControlType);
        };

        // Calling method in Control and sending property there :-)
        MyControl.PropertiesLoaded(this.MyEntity.SomeString);
      });
    }