+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Silverlight Plugin Crashes - Customer Designer Class

Silverlight Plugin Crashes - Customer Designer Class

4 posts, 0 answered
  1. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    22 Sep 2010
    Link to this post
    I added a few more custom designer class fields to the CoverFlow sample:
    RotationY="{Binding RotationY}"
    DistanceBetweenItems="{Binding DistanceBetweenItems}"
    DistanceFromSelectedItem="{Binding DistanceFromSelectedItem}"
    OffsetX="{Binding OffSetX}"

    The silverlight control shows up fine when loading the page normal, but when editing the page itself the page freezes for a moment and I receive a message saying silverlight plugin crashed (FF 3.6), what could be causing this?
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    23 Sep 2010
    Link to this post
    Hello Kristian,

    Thank you for using our services.

    Can you please enable Silverlight debugging from the web application project's properties (as in attached image)? This will allow you to see the actual exception being thrown from the Silverligh control. You can also put a break point on the Application_UnhandledException method in App.xaml.cs and see the exception when the control breaks in page edit mode.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    23 Sep 2010
    Link to this post

    Ah, in my designer when you put the control in place all of the setting i allow the user to change are initially set to 0 and some of the end up breaking the control, e.g ImageHeight, ImageWidth.

    I tried setting a value in coverflowdesigner.ascx but they still show up as 0, how would i setup an inital value? 

     

    <li
    <label for="ImageHeight">Image Height</label
    <input type="text" id="ImageHeight" class="sfTxt" value="300" /> 
    </li

     

     

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Sep 2010
    Link to this post
    Hello Kristian,

    Thank you for getting back to me.

    For this you will have to take an approach similar to the one used for passing the images collection. Bellow are the steps you have to take to pass settings to the Silverlight control:

    1) Expose public properties in the CoverFlowWidget control which will set the image width and height:
    [Category("CoverFlow Settings")]
    public double ImageHeight { get; set; }
     
    [Category("CoverFlow Settings")]
    public double ImageWidth { get; set; }

    2) When the collection of images is constructed add those settings to the hash table representing this collection:
    private List<Hashtable> GetImages()
    {
        List<Hashtable> results = new List<Hashtable>();
     
        //get  IQueryable of images from the Fluent API.
        var images = App.WorkWith().Images()
            .Where(
            (w) => w.Album.Title == this.AlbumTitle &&
                   w.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
             .Get();
     
        var authority = this.GetAuthorityUrl();
        foreach (Telerik.Sitefinity.Libraries.Model.Image v in images)
        {
            Hashtable table = new Hashtable();
            table.Add("Url", authority + v.MediaUrl);
            table.Add("Title", v.Title.ToString());
            table.Add("Width", this.ImageWidth.ToString());
            table.Add("Height", this.ImageHeight.ToString());
            results.Add(table);
        }
     
        return results;
    }

    3) In the control template of the CoverFlowWidget alter the call to SetItem method to pass the settings to the cover flow:
    <script type="text/javascript">
        function pluginLoaded(sender, args) {   // HTML version
     
            var imagesField = $get('<%= imagesField.ClientID %>');
            var imagesArr = Sys.Serialization.JavaScriptSerializer.deserialize(imagesField.value);
            slCtl = sender.getHost();
     
            for (idx in imagesArr) {
                slCtl.Content.mainPage.SetItem(imagesArr[idx]['Title'], imagesArr[idx]['Url'], imagesArr[idx]['Width'], imagesArr[idx]['Height']);
            }
        }
    </script>

    4) Change the MainPage class and the SitefinityImage class in the Silverlight project so that the SetItem method gets the images' width and heght:
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
     
        [ScriptableMember]
        public void SetItem(string title, string url, string width, string height)
        {
            this.coverFlow.Items.Add(new SitefinityImage(title, url, width, height));
        }
     
        [ScriptableMember]
        public void SetMethod(string test)
        {
            MessageBox.Show("debug");
        }
    }
     
    public class SitefinityImage
    {
        public string URL { get; set; }
        public string Title { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
     
        public SitefinityImage(string title, string url, string width,string height)
        {
            this.Title = title;
            this.URL = url;
            this.Width = double.Parse(width);
            this.Height = double.Parse(height);
        }
    }

    5) Finally change the XAML so that you set the height and width from the binder:
    <telerik:RadCoverFlow x:Name="coverFlow" IsReflectionEnabled="True">
        <telerik:RadCoverFlow.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <!--<TextBlock Text="{Binding Title}" />-->
                    <Image Width="{Binding Width}" Height="{Binding Height}" Source="{Binding URL}" />
                </StackPanel>
            </DataTemplate>
        </telerik:RadCoverFlow.ItemTemplate>
    </telerik:RadCoverFlow>

    Finally build the solution and go to the page editor to set the properties exposed.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
4 posts, 0 answered