I have a DataTemplate that I am using for a cell in a gridview. I would like to switch between the progress bar and the text/link block. Is there a way to hide an element so that it is removed from the flow and takes up no space while it is hidden (like "display:none" in CSS)? Is there a better way to approach this?
DataTemplate looks like:
<DataTemplate x:Key="DataTemplate2">
<StackPanel Height="40">
<TextBlock Visibility="{Binding ButtonVisibility}">
<Hyperlink Click="btn_Authorise">
<InlineUIContainer>
<TextBlock Text="{Binding Button}" />
</InlineUIContainer>
</Hyperlink>
</TextBlock>
<ProgressBar Value="{Binding Progress}"
Visibility="{Binding ProgressVisibility}"
Height="15"
Width="150"
Background="{DynamicResource NormalBrush}"
BorderThickness="0"
BorderBrush="#FF8D8D8D"
Style="{DynamicResource ProgressBarStyle1}" />
</StackPanel>
</DataTemplate>
Visibility.Collapsed
is probably what you need (as opposed to Visibility.Hidden
which still makes the control take part in layout calculations)
Also see the Visibility
enumeration reference.
Yep.
Visibility is an enumeration, Visible, Hidden, and Collapsed. Hidden is just non-visible, whereas Collapsed means it takes no space also
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With