This is a migrated thread and some comments may be shown as answers.

binding

1 Answer 40 Views
Book
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 1
Emil asked on 29 Jun 2012, 08:41 AM
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?

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 04 Jul 2012, 06:25 AM
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"

xmlns:viewModels="clr-namespace:Telerik.Windows.Examples.Book.Binding"
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
    {
xmlns:local="clr-namespace:WPFApplication1"
<local:PageCollection...

Kind regards,
Petar Mladenov
the Telerik team

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

Tags
Book
Asked by
Emil
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or