|
| 1 | +<Page x:Class="SettingsControlsExperiment.Samples.SettingsExpanderDragHandleSample" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" |
| 5 | + xmlns:controls="using:CommunityToolkit.WinUI.Controls" |
| 6 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 7 | + xmlns:local="using:SettingsControlsExperiment.Samples" |
| 8 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 9 | + mc:Ignorable="d"> |
| 10 | + |
| 11 | + <!-- |
| 12 | + Enabled the List view to drag its items and reorder them around, |
| 13 | + plus need SelectionMode None so the indicator doesn't appear when clicking on the drag region |
| 14 | + --> |
| 15 | + <ListView AllowDrop="True" |
| 16 | + CanDragItems="True" |
| 17 | + CanReorderItems="True" |
| 18 | + ItemsSource="{x:Bind MyDataSet}" |
| 19 | + SelectionMode="None"> |
| 20 | + <ListView.ItemTemplate> |
| 21 | + <DataTemplate x:DataType="local:ExpandedCardInfo"> |
| 22 | + <Grid> |
| 23 | + <Grid.ColumnDefinitions> |
| 24 | + <ColumnDefinition Width="Auto" /> |
| 25 | + <ColumnDefinition Width="*" /> |
| 26 | + </Grid.ColumnDefinitions> |
| 27 | + <!-- Provide a custom area that can be manipulated by the user, this could be before or after the card. --> |
| 28 | + <Border Width="36" |
| 29 | + Height="75" |
| 30 | + Margin="1,1,1,1" |
| 31 | + VerticalAlignment="Top" |
| 32 | + Background="Transparent" |
| 33 | + CornerRadius="{ThemeResource ControlCornerRadius}"> |
| 34 | + <TextBlock HorizontalAlignment="Center" |
| 35 | + VerticalAlignment="Center" |
| 36 | + FontFamily="Segoe UI Symbol" |
| 37 | + FontSize="20" |
| 38 | + Foreground="{ThemeResource TextFillColorSecondaryBrush}" |
| 39 | + Text="⠿" /> |
| 40 | + <!-- Use Behaviors to hover on pointer --> |
| 41 | + <Interactivity:Interaction.Behaviors> |
| 42 | + <Interactivity:EventTriggerBehavior EventName="PointerEntered"> |
| 43 | + <Interactivity:ChangePropertyAction PropertyName="Background"> |
| 44 | + <Interactivity:ChangePropertyAction.Value> |
| 45 | + <SolidColorBrush Color="{ThemeResource ControlFillColorDefault}" /> |
| 46 | + </Interactivity:ChangePropertyAction.Value> |
| 47 | + </Interactivity:ChangePropertyAction> |
| 48 | + </Interactivity:EventTriggerBehavior> |
| 49 | + <Interactivity:EventTriggerBehavior EventName="PointerExited"> |
| 50 | + <Interactivity:ChangePropertyAction PropertyName="Background"> |
| 51 | + <Interactivity:ChangePropertyAction.Value> |
| 52 | + <SolidColorBrush Color="Transparent" /> |
| 53 | + </Interactivity:ChangePropertyAction.Value> |
| 54 | + </Interactivity:ChangePropertyAction> |
| 55 | + </Interactivity:EventTriggerBehavior> |
| 56 | + </Interactivity:Interaction.Behaviors> |
| 57 | + </Border> |
| 58 | + <!-- Standard Settings Expander (could also just be a Card) --> |
| 59 | + <controls:SettingsExpander Grid.Column="1" |
| 60 | + Description="{x:Bind Info}" |
| 61 | + Header="{x:Bind Name}" |
| 62 | + IsExpanded="{x:Bind IsExpanded, Mode=TwoWay}"> |
| 63 | + |
| 64 | + <ToggleSwitch IsOn="{x:Bind IsExpanded, Mode=TwoWay}" |
| 65 | + OffContent="Off" |
| 66 | + OnContent="On" /> |
| 67 | + |
| 68 | + <controls:SettingsExpander.Items> |
| 69 | + <controls:SettingsCard Header="{x:Bind LinkDescription}"> |
| 70 | + <HyperlinkButton Content="{x:Bind Url}" |
| 71 | + NavigateUri="{x:Bind Url}" /> |
| 72 | + </controls:SettingsCard> |
| 73 | + </controls:SettingsExpander.Items> |
| 74 | + </controls:SettingsExpander> |
| 75 | + </Grid> |
| 76 | + </DataTemplate> |
| 77 | + </ListView.ItemTemplate> |
| 78 | + <!-- Customize Size of Item Container from ListView --> |
| 79 | + <ListView.ItemContainerStyle> |
| 80 | + <Style BasedOn="{StaticResource DefaultListViewItemStyle}" |
| 81 | + TargetType="ListViewItem"> |
| 82 | + <Setter Property="Margin" Value="0" /> |
| 83 | + <Setter Property="Padding" Value="4" /> |
| 84 | + </Style> |
| 85 | + </ListView.ItemContainerStyle> |
| 86 | + <!-- Hides the overall highlight from the ListView Container --> |
| 87 | + <ListView.Resources> |
| 88 | + <SolidColorBrush x:Key="ListViewItemBackgroundPointerOver" |
| 89 | + Color="Transparent" /> |
| 90 | + </ListView.Resources> |
| 91 | + </ListView> |
| 92 | +</Page> |
0 commit comments