felix
felix

Reputation: 31

Dynamic ItemTemplate with event on windows phone

I need that every user of my application can define his own item template to a jumplist. It's working fine, but I´ve got a problem when the template is something like this:

<DataTemplate x:Key="ItemTemplate">
        <Grid HorizontalAlignment="Stretch" Margin="0,0,0,20">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="400" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <TextBlock 
                Text="{Binding RazonSocial}" 
                Tap="Clientes_Tap"
                FontSize="{StaticResource PhoneFontSizeNormal}" 
                Grid.Column="0" 
                VerticalAlignment="Top"/>

        </Grid>
</DataTemplate>

The problem is the line Tap="Clientes_Tap". Without this line it works fine, I read template from file and I assign it to jumplist. But with this line I get an error.

Thanks

Upvotes: 0

Views: 157

Answers (1)

MatthieuGD
MatthieuGD

Reputation: 4602

It's because you can't instantiate/deserialize a control from a file when your XAML contains reference to a method (here the event handler)

Maybe you can "attach" your event handler after you read the XAML or use a binding expression using something like the event-to-command of MVVM Light toolkit?

http://mvvmlight.codeplex.com/

Upvotes: 1

Related Questions