0
votes

I'm using the default Windows Store templates with an application I am writing.

I want the first item in a listview highlighted; I have achieved this using a custom itemtemplateSelector.

The problem that I have is that I need to modify the style when the page is snapped.

The 'default' templates don't use a template selector so simply change the itemTemplate in the visualstate storyboard.

If I amend this code to change itemTemlateSelector (storyboard.TargetProperty="itemTemplateSelector") I get a runtime error.

I then tried amending my DatatemplateSelector class to take account of ApplicationViewState: This works if the page loads into the snapped / full screen state but does not change the templates used when the application view state changes.

Is there a way of 'refreshing' the Listview so that it re-applies the templates?

Is there an alternative way of doing this?

Thanks for any help/advice.

1
did you ever get this figured out? the solution below didn't work for me, as I got the same result as you where it only works when you LOAD in a specific mode, not if you SWITCH modes. I'd appreciate if you can share any solutions or insight on what worked for you, thanks!SelAromDotNet

1 Answers

0
votes

The sample templates use two different lists, one for Snapped and one for the rest. This is a very easy approach to take.

I have no tested this next one, but if your page is a LayoutAwarePage then you could change the selector in the DetermineVisualState method.

    protected override string DetermineVisualState(ApplicationViewState viewState)
    {
        if (viewState == ApplicationViewState.Snapped)
        {
            // change to snapped selector
        }
        else
        {
            // change to regular selector
        }
        return base.DetermineVisualState(viewState);
    }