Meme Machine
Meme Machine

Reputation: 1039

Change DataTemplate Child Dynamically

I have a ListView which has a column for checkboxes. When a checkbox is checked, I want to swap it out with a progress ring. Then, when the activity I want is completed, I can hide the progress ring and display the checked checkbox. Is this possible? A DataTemplate only seems to accept one child

<GridViewColumn x:Name="StatusHeader" Header="Status" Width="50">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <CheckBox Margin="5, 0" IsChecked="{Binding loaded}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

enter image description here

Upvotes: 0

Views: 67

Answers (1)

L&#233;o SALVADOR
L&#233;o SALVADOR

Reputation: 764

The DataTemplate contains only one child, but this child can be without problem a Container such as a Grid or a StackPanel, which will contain your elements:

<GridViewColumn x:Name="StatusHeader" Header="Status" Width="50">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <StackPanel>
                <CheckBox Margin="5, 0" IsChecked="{Binding loaded}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
                <ProgressBar />
            </StackPanel>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

Upvotes: 1

Related Questions