Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [60.0.5]
- Test

## [60.0.4]
- [ContextMenu] Added `ContextMenuItem.IsEnabled` bindable property to disable individual context menu items. Disabled items appear grayed out and cannot be tapped.
- [ContextMenu] Added `ContextMenuEffect.IsEnabled` attached property to enable/disable an entire context menu on an element. When disabled, the context menu will not open at all.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>

<dui:ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:dui="http://dips.com/mobile.ui"
xmlns:local="clr-namespace:Components.ComponentsSamples.CollectionView"
x:Class="Components.ComponentsSamples.CollectionView.CollectionViewSamples"
x:DataType="local:CollectionViewSamplesViewModel"
Title="CollectionView">

<dui:ContentPage.BindingContext>
<local:CollectionViewSamplesViewModel />
</dui:ContentPage.BindingContext>

<Grid RowDefinitions="Auto, *">

<!-- Action buttons -->
<dui:ScrollView Orientation="Horizontal"
Grid.Row="0">
<HorizontalStackLayout Spacing="{dui:Sizes size_1}"
Padding="{dui:Thickness Left=content_margin_medium, Right=content_margin_medium, Top=size_1, Bottom=size_1}">
<dui:Button Style="{dui:Styles Button=DefaultSmall}"
Text="Add First"
Command="{Binding AddFirstCommand}" />
<dui:Button Style="{dui:Styles Button=DefaultSmall}"
Text="Add Last"
Command="{Binding AddLastCommand}" />
<dui:Button Style="{dui:Styles Button=DefaultSmall}"
Text="Add Middle"
Command="{Binding AddMiddleCommand}" />
<dui:Button Style="{dui:Styles Button=GhostSmall}"
Text="Remove First"
Command="{Binding RemoveFirstCommand}" />
<dui:Button Style="{dui:Styles Button=GhostSmall}"
Text="Remove Last"
Command="{Binding RemoveLastCommand}" />
<dui:Button Style="{dui:Styles Button=GhostSmall}"
Text="Remove Middle"
Command="{Binding RemoveMiddleCommand}" />
<dui:Button Style="{dui:Styles Button=GhostSmall}"
Text="Clear All"
Command="{Binding ClearAllCommand}" />
<dui:Button Style="{dui:Styles Button=CallToActionSmall}"
Text="Reset"
Command="{Binding ResetCommand}" />
</HorizontalStackLayout>
</dui:ScrollView>

<!-- CollectionView with AutoHideLastDivider and auto corner radius -->
<dui:CollectionView ItemsSource="{Binding Items}"
dui:Layout.AutoHideLastDivider="True"
Grid.Row="1">
<dui:CollectionView.ItemTemplate>
<DataTemplate x:DataType="local:CollectionViewSampleItem">
<dui:ListItem Title="{Binding Title}"
HasBottomDivider="True" />
</DataTemplate>
</dui:CollectionView.ItemTemplate>
</dui:CollectionView>

</Grid>

</dui:ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Components.ComponentsSamples.CollectionView;

public partial class CollectionViewSamples
{
public CollectionViewSamples()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System.Collections.ObjectModel;
using System.Windows.Input;
using DIPS.Mobile.UI.MVVM;

namespace Components.ComponentsSamples.CollectionView;

public class CollectionViewSamplesViewModel : ViewModel
{
private int m_nextId;

public ObservableCollection<CollectionViewSampleItem> Items { get; } = new();

public ICommand AddFirstCommand { get; }
public ICommand AddLastCommand { get; }
public ICommand AddMiddleCommand { get; }
public ICommand RemoveFirstCommand { get; }
public ICommand RemoveLastCommand { get; }
public ICommand RemoveMiddleCommand { get; }
public ICommand ClearAllCommand { get; }
public ICommand ResetCommand { get; }

public CollectionViewSamplesViewModel()
{
AddFirstCommand = new Command(AddFirst);
AddLastCommand = new Command(AddLast);
AddMiddleCommand = new Command(AddMiddle);
RemoveFirstCommand = new Command(RemoveFirst);
RemoveLastCommand = new Command(RemoveLast);
RemoveMiddleCommand = new Command(RemoveMiddle);
ClearAllCommand = new Command(ClearAll);
ResetCommand = new Command(Reset);

Reset();
}

private void AddFirst()
{
m_nextId++;
Items.Insert(0, new CollectionViewSampleItem($"New first #{m_nextId}"));
}

private void AddLast()
{
m_nextId++;
Items.Add(new CollectionViewSampleItem($"New last #{m_nextId}"));
}

private void AddMiddle()
{
if (Items.Count == 0)
{
AddLast();
return;
}

m_nextId++;
var middleIndex = Items.Count / 2;
Items.Insert(middleIndex, new CollectionViewSampleItem($"New middle #{m_nextId}"));
}

private void RemoveFirst()
{
if (Items.Count > 0)
Items.RemoveAt(0);
}

private void RemoveLast()
{
if (Items.Count > 0)
Items.RemoveAt(Items.Count - 1);
}

private void RemoveMiddle()
{
if (Items.Count > 0)
Items.RemoveAt(Items.Count / 2);
}

private void ClearAll()
{
Items.Clear();
}

private void Reset()
{
Items.Clear();
m_nextId = 5;
Items.Add(new CollectionViewSampleItem("Item 1"));
Items.Add(new CollectionViewSampleItem("Item 2"));
Items.Add(new CollectionViewSampleItem("Item 3"));
Items.Add(new CollectionViewSampleItem("Item 4"));
Items.Add(new CollectionViewSampleItem("Item 5"));
}
}

public class CollectionViewSampleItem(string title)
{
public string Title { get; } = title;
}
2 changes: 2 additions & 0 deletions src/app/Components/REGISTER_YOUR_SAMPLES_HERE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Components.ComponentsSamples.BottomSheets;
using Components.ComponentsSamples.Buttons;
using Components.ComponentsSamples.Chips;
using Components.ComponentsSamples.CollectionView;
using Components.ComponentsSamples.ContextMenus;
using Components.ComponentsSamples.Counters;
using Components.ComponentsSamples.ImageCapturing;
Expand Down Expand Up @@ -78,6 +79,7 @@ public static List<Sample> RegisterSamples()
new(SampleType.Components, "TIFF Viewer", () => new TiffViewerSample()),
new(SampleType.Components, "Toolbar", () => new ToolbarSamples(), isModal: true),
new(SampleType.Accessibility, "VoiceOver/TalkBack", () => new VoiceOverSamples()),
new(SampleType.Components, "CollectionView", () => new CollectionViewSamples()),



Expand Down
Loading