2 posts, 0 answers
  1. Emil
    Emil avatar
    2 posts
    Member since:
    Jun 2012

    Posted 29 Jun 2012 Link to this post

    First, I'm a beginner. I saw the examples/demos but all asume that the list of pages for the book is hardcoded in the program. How to make a book that can load any number of pictures by simply placing those pictures in a folder? Or, better, if those files are listed in a text file or xml file how to read from this file and load the items in the book.
    Another issue: In the binding example you are using a xmlns:viewModels="clr-namespace:Telerik.Windows.Examples.Book.Binding". Durring build I get an error about that line (I have exacly the same lines of code as your example and added the same pictures in the project). Can you help me find what I'm missing?
  2. Petar Mladenov
    Petar Mladenov avatar
    3143 posts

    Posted 04 Jul 2012 Link to this post

    Hi Emil,

    Supposing that you have pictures in folder, you can create a method that iterates over the folder and creates a List of ViewModels. A ViewModel class can hold a Name(string) of the picture and Path (of type Uri) to it. Then you have to create template for the Left and Right Pages and bind the ItemSource of the Book to the list you created. Nothing special here, the mentioned demo and this help article should be a good starting point.
    This msdn article may also be helpful.
    As for the demo and the namespace viewmodels"

    you can see it is only used to define the PageCollection:
    <viewModels:PageCollection x:Key="Pages" />
    Which is actually in the MainPage.cs file:
    namespace Telerik.Windows.Examples.Book.Binding
        public class PageCollection : ObservableCollection<Page>
    You can create this PageCollection class (or class with similar name) and use the local namespace pointing, for example like so:
    namespace WPFApplication1
        public class PageCollection

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top