Maxime FRAPPAT

Hum …no thanks ! – Lordinaire

Category: C# (Page 11 of 12)

[WinRT] How to create a game using FMOD

I wrote several posts about create a game who used the FMOD Ex library. You can read those posts, in french, on the blog hub of my company (Infinite Square) :

visu_monstre

Have fun !

[WinRT] Refresh ItemTemplateSelector display

Sometimes, we want to display a list of items with different layout like details, mozaic, minimize, … You can use an ItemTemplateSelector to achieve this but there’s a little trick because ItemTemplateSelector is one shot :

XAML

<Button Content="Change display" Click="ChangeDisplayType" />

<GridView x:Name="content" ItemsSource="{Binding Contents}">
    <GridView.ItemTemplateSelector>
        <Common:MyTemplateSelector />
    </GridView.ItemTemplateSelector>
</GridView>

Code behind

private void ChangeDisplayType(object sender, RoutedEventArgs e)
{
    // TODO : Change display type like list, mosaic, detail, ... 

    // We need to do this to refresh the size of the each items 
    // because the ItemTemplateSelector is one shot
    var temp = content.ItemTemplateSelector;
    content.ItemTemplateSelector = null;
    content.ItemTemplateSelector = temp;
}

Have fun !

Page 11 of 12

Powered by WordPress & Theme by Anders Norén

%d bloggers like this: