locked
Not able to use Datacontext to bind data to Callisto livetiles RRS feed

  • Question

  • This is the Live Tile template I am using

    <callisto:LiveTile x:Name="liveTile1" Grid.Row="1" Grid.Column="0"
             ItemsSource="{Binding}"
             BorderBrush="White" BorderThickness="1"
             Margin="15" Background="#FFCAD83E">
                    <callisto:LiveTile.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <StackPanel>
                                    <TextBlock Text="Temp" FontWeight="SemiBold" 
                                               FontSize="25" FontFamily="Segoe UI Semibold" 
                                               Margin="10,20,0,0">
                                    </TextBlock>
                                    <StackPanel Orientation="Horizontal" Margin="0,20,0,0">
                                       <TextBlock Text="{Binding Name}" x:Name="CrudeStMainTankName"
                                                  FontWeight="Light"
                                                  FontSize="20"
                                                  FontFamily="Segoe UI Semilight"
                                                  Margin="0,0,0,0">
                                       </TextBlock>
                                       <TextBlock Text="{Binding Value}" x:Name="CrudeStMainTankValue"
                                                  FontWeight="Light"
                                                  FontSize="20" 
                                                  FontFamily="Segoe UI Semilight"
                                                  Margin="0,00,0,0">
                                        </TextBlock>
                                    </StackPanel>
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                  </callisto:LiveTile.ItemTemplate>
     </callisto:LiveTile>

    This is how I am assigning my DataContext to this live Tile

    liveTile1.DataContext = cds.ComponentCollection[0];

    I have tried to debug it but I am going nowhere.

    Now cds.ComponentCollection[0] retrieves an item from the collection contaning name, type and value and from this collection item , I am binding Textblock property Name to Item Property Name and Textblock property Value to Item Property Value.
    Can anybody please help me on how to get this working?

    Thursday, May 9, 2013 11:13 PM

Answers

  • I'm not familiar with the callisto livetile however from what I can see you're setting a single entity (Whatever ComponentCollection[0] is) to be the ItemsSource.

    Looks like ItemsSource is expecting an IEnumerable<> as opposed to an object.

    Quick way to test set your datacontext to this:

    liveTile1.DataContext = cds.ComponentCollection;


    British Airways Inspiration App & rara music

    • Marked as answer by Jesse Jiang Wednesday, May 15, 2013 4:51 AM
    Friday, May 10, 2013 3:38 PM