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

Carousel User control Binding

2 Answers 80 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Rick Mueller
Top achievements
Rank 1
Rick Mueller asked on 21 Sep 2010, 10:17 PM
Hello,

I'm trying to have the carousel bind to xml data.

I Have a grid with textboxes, Image, and listbox.
Using xmlDataProvider and CollectionViewSource I'm able to point to the data file.
The issue is the data is grouped by employee name, the listbox populates the current list for that certain employee. But the IMage and other Employee info loses the binding. The Carousel populates the correct amount of employees etc.

 When I Change the Data Content the Image and Employee Info binds, but the listbox data loses its binding and the Carousel populates every node in the xml file.

Here is the code:

XML FIle
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Table>
        <RecipeID>117</RecipeID>
        <RecipeName>1620 Shrimp</RecipeName>
        <PrepTime>0.00347222222222222</PrepTime>
        <Station>PULL</Station>
        <Employee>Josa Sosa</Employee>
        <Image>Male.jpg</Image>
    </Table>
    <Table>
        <RecipeID>116</RecipeID>
        <RecipeName>26/30 Shrimp</RecipeName>
        <PrepTime>0.00347222222222222</PrepTime>
        <Station>PULL</Station>
        <Employee>Josa Sosa</Employee>
        <Image>Male.jpg</Image>
    </Table>
    <Table>
        <RecipeID>42</RecipeID>
        <RecipeName>Ale and Cheddar Soup</RecipeName>
        <PrepTime>0.03125</PrepTime>
        <Station>SS</Station>
        <Employee>Maria Anders</Employee>
        <Image>Female.jpg</Image>
    </Table>
    <Table>
        <RecipeID>41</RecipeID>
        <RecipeName>Alfredo Sauce</RecipeName>
        <PrepTime>0.03125</PrepTime>
        <Station>SS</Station>
        <Employee>Maria Anders</Employee>
        <Image>Female.jpg</Image>
    </Table>
    <Table>
        <RecipeID>126</RecipeID>
        <RecipeName>American Cheese Portioned/Wrapped</RecipeName>
        <PrepTime>0.00347222222222222</PrepTime>
        <Station>BR</Station>
        <Employee>Rick Mueller</Employee>
        <Image>Male.jpg</Image>
    </Table>
    <Table>
        <RecipeID>242</RecipeID>
        <RecipeName>Apple Cinn Scones</RecipeName>
        <PrepTime>0.0104166666666667</PrepTime>
        <Station>PULL</Station>
        <Employee>Josa Sosa</Employee>
        <Image>Male.jpg</Image>

The XAML:
<UserControl.Resources>
         
          <XmlDataProvider x:Key="ProductionData"
            Source="Database/ProductionData.xml"
            XPath="NewDataSet1/Table"/>
        <CollectionViewSource x:Key="CallPrepData"
            Source="{StaticResource ProductionData}">
         
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="Station" Direction="Ascending"/>
                                <scm:SortDescription PropertyName="RecipeName"/>
                                <scm:SortDescription PropertyName="Station"/>
                                <scm:SortDescription PropertyName="PrepTime"/>
                                <scm:SortDescription PropertyName="RecipeID"/>
                                <scm:SortDescription PropertyName="Image"/>
                                <scm:SortDescription PropertyName="Employee" Direction="Ascending"/>
            </CollectionViewSource.SortDescriptions>
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Employee"/>
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
 
 <DataTemplate x:Key="TableTemplate">
 <Grid >
           
        <Image Height="107" HorizontalAlignment="Left" Source="{Binding XPath=IMage}" Margin="12,12,0,0" x:Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="120" />
        <TextBlock Height="40" HorizontalAlignment="Left" Margin="157,12,0,0" x:Name="Employeename" Text="{Binding XPath=Employee}" VerticalAlignment="Top" Width="180"  FontSize="22"/>
        <TextBlock Height="23" HorizontalAlignment="Left"  Margin="157,43,0,0" x:Name="textBlock21" Text="Station:" VerticalAlignment="Top" Width="82" FontSize="12" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="157,66,0,0" x:Name="textBlock2" Text="Total Items" VerticalAlignment="Top" Width="82" FontSize="12" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="157,96,0,0" x:Name="textBlock3" Text="Total Prep Time:" VerticalAlignment="Top" Width="92"  FontSize="12" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="256,66,50,0" x:Name="textBlock4" Text="{Binding ItemCount}" VerticalAlignment="Top" Width="44"  FontSize="12" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="255,96,0,0" x:Name="textBlock5" Text="180 min" VerticalAlignment="Top" Width="82"  FontSize="12" />
        <TextBlock Height="23" HorizontalAlignment="Left" Margin="255,43,0,0" x:Name="Stat" Text="{Binding XPath=Station}" VerticalAlignment="Top" Width="82"  FontSize="12" />
         
         
     
        <ListBox
        Margin="0,120,0,0"
        HorizontalAlignment="Left" 
        x:Name="listBox2"
        Height="490"
        Background="Transparent"
        BorderBrush="Transparent"
        ItemsSource="{Binding Items}" 
        VerticalAlignment="Top" Width="449">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <Grid>
                         <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="60*" />
                                  <ColumnDefinition Width="241*" />
                         </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding XPath=RecipeID}"
                    Grid.Column="1" FontSize="16"/>
                    <TextBlock Text="{Binding XPath=RecipeName}" 
                    Grid.Column="2" FontSize="16" Margin="50,0,0,0"/>
                        </Grid>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
        </DataTemplate>
    </UserControl.Resources>
     
     
     
     
 
    <Grid Margin="0,0,8,180" DataContext="{Binding Source={StaticResource CallPrepData}}">
     
        <telerik:RadCarousel
        Margin="0,0,0,0"
        Background="Transparent"
        ItemsSource="{Binding Groups}"
        ItemTemplate="{DynamicResource TableTemplate}" />
          
     
    </Grid>
</UserControl>


Thoughts?
Thank you

Rick Mueller

2 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 22 Sep 2010, 04:15 PM
Hi Rick Mueller,

When the carousel is bound to the Groups collection its items will be group items which do not have properties like IMage, Employee, etc. Maybe you should try to move all of those binding to ListBox.ItemTemplate.


Greetings,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rick Mueller
Top achievements
Rank 1
answered on 22 Sep 2010, 07:12 PM
Hello Milan,

I tried what you suggested, it populated a image for every item.
Just want the Image to appear once and not in the listbox.

Thank you
Tags
Carousel
Asked by
Rick Mueller
Top achievements
Rank 1
Answers by
Milan
Telerik team
Rick Mueller
Top achievements
Rank 1
Share this question
or