locked
How to use converter within DataTemplate RRS feed

  • Question

  • Hi,

    I am having trouble to use converter within a DataTemplate.  The code compile without errors, but the converter never get called.  Below is the DataTemplate code.

        <DataTemplate x:Key="Standard130ItemTemplate">
            <Grid>
                <Grid.Resources>
                    <common:BooleanToVisibilityConverter x:Key="boolToVisibiltyConverter" />
                </Grid.Resources>
                <StackPanel Orientation="Horizontal" Width="528" Visibility="{Binding ShowTest, Converter={StaticResource boolToVisibiltyConverter}, Mode=OneWay}">
                    <StackPanel VerticalAlignment="Top" Margin="80,0,20,0">
                        <TextBlock Text="{Binding Title}" FontSize="24" FontWeight="Normal" Foreground="{Binding TestColor}" TextWrapping="NoWrap" />
                        <TextBlock Text="{Binding Description}" Width="360" Foreground="{Binding TestColor}" TextWrapping="Wrap" Height="Auto" />
                    </StackPanel>
                </StackPanel>
            </Grid>
        </DataTemplate>


    Tuesday, November 13, 2012 2:22 AM

Answers

  • Hi Dave,

    Thanks for your reply.   I found out that it starts working after rebuilding the whole project, so the above code is working fine.

    • Marked as answer by Albert Pun Tuesday, November 13, 2012 5:45 PM
    Tuesday, November 13, 2012 5:44 PM

All replies

  • and what if you just declare the converter in the page resources or app resources?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, November 13, 2012 3:53 PM
  • Hi Dave,

    Thanks for your reply.   I found out that it starts working after rebuilding the whole project, so the above code is working fine.

    • Marked as answer by Albert Pun Tuesday, November 13, 2012 5:45 PM
    Tuesday, November 13, 2012 5:44 PM
  • but performance wise its still beter to put the converter in the page resources. your getting lot of instances in the way you doing it now


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, November 13, 2012 6:23 PM