Click here to Skip to main content
15,066,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As described in MVVM Friendly DataTemplate switching[^] I wanted to Switch my Usercontrols depending on an integer variable.

Sadly, the screen stays white, and I cannot figure out why

What I have tried:

XML
<Window.Resources>
        <ControlTemplate x:Key="DeciderControl">
            <userControls:DeciderControl/>
        </ControlTemplate>
</Window.Resources>


    <Grid>
        <ListBox>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Control x:Name="decider" Template="{StaticResource DeciderControl}"/>
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding IntTest}" Value="1">
                            <Setter TargetName="decider" Property="Template" Value="{StaticResource DeciderControl}"/>
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        </Grid>



IntTest is always 1, set in the Constructor of my ViewModel.
the userControl also works - if I just show it in the ListBox it's ok.
Posted
Updated 17-Mar-16 13:25pm
v2

1 solution

Ask the author of this article, Pete O'Hanlon, by joining the discussion at the "Comments and Discussions" section on the article page: MVVM Friendly DataTemplate switching[^].

Click "Add a Comment or Question" to ask your question. Peter will get a notification and a change to answer you. From what I know, he is quite a responsive person.

—SA
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900