Home > Back-end >  Change DataTemplate Child Dynamically
Change DataTemplate Child Dynamically

Time:02-10

I have a ListView which has a column for checkboxes. When a checkbox is checked, I want to swap it out with a enter image description here

CodePudding user response:

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>
  • Related