Add Q3 Coverflow to Grid runtime

2 posts, 1 answers
  1. Henk
    Henk avatar
    113 posts
    Member since:
    Apr 2006

    Posted 05 Nov 2009 Link to this post

    I try to add a CoverFlow to a grid at runtime.
    In the Coverflow Images should be shown.
    ItemsSource of the CoverFlow is connected to a collection of objects that have a ImageURL property.
    ImageURL value is for instance "/Images/nature1.png"
    Images are stored in "ClientBin/Images"

    CoverFlow = new RadCoverFlow(){ReflectionStartAlpha=100,  
                                   ReflectionRelativeHeight = 0.3,  
                                   CameraY = -120,  
                                   ItemMaxHeight = 140,  
                                   Height = 200 };  
    Grid1.Children.Add(CoverFlow);  
    CoverFlow.DisplayMemberPath = "ImageUrl";  
    AntwoordCoverFlow.ItemsSource = ImageCollection; 

    If I run the application only the ImageURL is shown as text in the CoverFlow.
    In the Q2 version I had no problem.
    Is an item template mandatory for the items in the CoverFlow in Q3? If yes how can I assign it in code behind. I don't have a XAML file.
  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 05 Nov 2009 Link to this post

    Hi Henk,

    Infortunately setting ItemTemplate is mandatory at this time. You could set it from code-behind using XamlReader (in Silverlight you cannot create DataTemplate purely with code) and the string representation of the template XAML. For example:

    string data = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""><Image Source=""{Binding ImageUrl}"" /></DataTemplate>";

    DataTemplate template = (DataTemplate)XamlReader.Load(data);

    Best wishes,
    Valeri Hristov
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
Back to Top