This control can switch the display content according to the selected state, and in some cases can replace ToggleButton
.
1
| public class ToggleBlock : Control
|
Attributes
Property |
Description |
Default Value |
Remarks |
IsChecked |
Is checked |
false |
|
CheckedContent |
The content displayed when selected |
|
|
UnCheckedContent |
The content displayed when unchecked |
|
|
IndeterminateContent |
The content displayed when the selected state is unknown |
|
|
ToggleGesture |
|
|
|
Case
1 2 3 4 5 6 7
| <hc:ToggleBlock> <hc:ToggleBlock.UnCheckedContent> </hc:ToggleBlock.UnCheckedContent> <hc:ToggleBlock.CheckedContent> </hc:ToggleBlock.CheckedContent> </hc:ToggleBlock>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <hc:ToggleBlock IsChecked="{Binding DataGot}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"> <hc:ToggleBlock.UnCheckedContent> <hc:LoadingCircle IsRunning="{Binding DataGot,Converter={StaticResource Boolean2BooleanReConverter}}"/> </hc:ToggleBlock.UnCheckedContent> <hc:ToggleBlock.CheckedContent> <ListBox Background="Transparent" ItemContainerStyle="{StaticResource ListBoxItemCustom}" BorderThickness="0" ItemsSource="{Binding DataList}" ItemsPanel="{StaticResource FluidMoveBehaviorWrapPanelItemsPanelTemplate}"> <ListBox.ItemTemplate> <DataTemplate> <userControl:Avatar DisplayName="{Binding DisplayName}" Link="{Binding Link}" Source="{Binding AvatarUri}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </hc:ToggleBlock.CheckedContent> </hc:ToggleBlock>
|