generate Grid from template

Posted by theXs on Stack Overflow See other posts from Stack Overflow or by theXs
Published on 2010-12-21T14:50:45Z Indexed on 2010/12/21 14:54 UTC
Read the original article Hit count: 247

Filed under:

Howdy, I've got another question regarding phone 7... I want to generate a couple of Grids in a stackpanel - since they all have the same layout I thought it would be a great idea to use DataTemplates ...

But then I found that the GRID Object has no "DataTemplate" Property and now I'm kinda stuck ... the template which I use is the following:

        <DataTemplate x:Key="Speise">
            <Grid>
                <TextBlock Height="36" Margin="8,43,104,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
                <TextBlock HorizontalAlignment="Right" Height="36" Margin="0,44,8,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="92"/>
            </Grid>
        </DataTemplate>

The way I now thought of creating my objects is:

Grid blubber = (Grid)this.Resources["Speise"];

But that is not working ... I think it's again a really short thing, but I have no clue of how to google for it :(

© Stack Overflow or respective owner

Related posts about windows-phone-7