diff --git a/DemoApp/DemoApp/Platforms/Windows/App.xaml b/DemoApp/DemoApp/Platforms/Windows/App.xaml index 687959f6..501e14aa 100644 --- a/DemoApp/DemoApp/Platforms/Windows/App.xaml +++ b/DemoApp/DemoApp/Platforms/Windows/App.xaml @@ -1,14 +1,16 @@ - - - - - - 0 - 0 - + + + + + + 0 + 0 + diff --git a/DemoApp/DemoApp/Views/ListViewSamplePage.xaml b/DemoApp/DemoApp/Views/ListViewSamplePage.xaml index f9c5c2e8..fdd0fba4 100644 --- a/DemoApp/DemoApp/Views/ListViewSamplePage.xaml +++ b/DemoApp/DemoApp/Views/ListViewSamplePage.xaml @@ -2,36 +2,28 @@ - - + + - + - - - - - - - - - - - - - - + + VerticalOptions="Center" + HorizontalOptions="Center" + HeightRequest="80" + WidthRequest="80" /> - @@ -59,34 +74,38 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/DemoApp/DemoApp/Views/ListViewSamplePage.xaml.cs b/DemoApp/DemoApp/Views/ListViewSamplePage.xaml.cs index 6e34b448..7ea667a5 100644 --- a/DemoApp/DemoApp/Views/ListViewSamplePage.xaml.cs +++ b/DemoApp/DemoApp/Views/ListViewSamplePage.xaml.cs @@ -20,11 +20,14 @@ public ListViewSamplePage() #region Private Methods private void OnCellGroupButtonChanged(object sender, TMRadioButtonEventArgs e) { - textCellList.ItemTemplate = e.RadioButtonIndex switch + if (e.RadioButtonIndex == 0) { - 1 => ViewCell, - _ => TextCell - }; + textCellList.ItemTemplate = TextCell; + } + else + { + textCellList.ItemTemplate = ViewCell; + } } #endregion } diff --git a/Trimble.Modus.Components/Controls/ListView/TMListView.xaml.cs b/Trimble.Modus.Components/Controls/ListView/TMListView.xaml.cs index 5aecc6b7..d397c288 100644 --- a/Trimble.Modus.Components/Controls/ListView/TMListView.xaml.cs +++ b/Trimble.Modus.Components/Controls/ListView/TMListView.xaml.cs @@ -1,8 +1,6 @@ using System.Collections; using System.Windows.Input; -using Trimble.Modus.Components.Constant; using Trimble.Modus.Components.Enums; -using Trimble.Modus.Components.Helpers; namespace Trimble.Modus.Components; @@ -13,13 +11,13 @@ public partial class TMListView : ListView #endregion #region Bindable Properties public static new readonly BindableProperty SelectionModeProperty = - BindableProperty.Create(nameof(SelectionMode), typeof(ListSelectionMode), typeof(TMListView),propertyChanged: OnSelectionModeChanged); + BindableProperty.Create(nameof(SelectionMode), typeof(ListSelectionMode), typeof(TMListView), propertyChanged: OnSelectionModeChanged); public static readonly BindableProperty SelectionChangedCommandProperty = BindableProperty.Create(nameof(SelectionChangedCommand), typeof(ICommand), typeof(TMListView)); public static readonly BindableProperty SelectableItemsProperty = - BindableProperty.Create(nameof(SelectableItems), typeof(List), typeof(TMListView),propertyChanged: OnSelectableItemsChanged); + BindableProperty.Create(nameof(SelectableItems), typeof(List), typeof(TMListView), propertyChanged: OnSelectableItemsChanged); #endregion #region Public properties @@ -33,13 +31,13 @@ public List SelectableItems { get => (List)GetValue(SelectableItemsProperty); set => SetValue(SelectableItemsProperty, value); - + } public new ListSelectionMode SelectionMode { get => (ListSelectionMode)GetValue(SelectionModeProperty); set => SetValue(SelectionModeProperty, value); - + } public new IEnumerable ItemsSource { @@ -51,8 +49,13 @@ public List SelectableItems public TMListView() { HasUnevenRows = true; + if (DeviceInfo.Platform == DevicePlatform.WinUI) + { + SetDynamicResource(BackgroundColorProperty, "CellDefaultBackgroundColor"); + } + SeparatorVisibility = SeparatorVisibility.None; ItemTapped += ListViewItemTapped; - (this as ListView)?.SetValue(ListView.SelectionModeProperty, ListViewSelectionMode.Single); + (this as ListView)?.SetValue(ListView.SelectionModeProperty, ListViewSelectionMode.Single); SelectableItems = new List { }; } #endregion @@ -125,22 +128,22 @@ private void UpdateCellColor() { if (SelectableItems.Contains(textCell.BindingContext)) { - textCell.SetDynamicResource(TextCell.BackgrondColorProperty, "CellSelectedBackgroundColor"); + textCell.SetDynamicResource(TextCell.BackgroundColorProperty, "CellSelectedBackgroundColor"); } else { - textCell.SetDynamicResource(TextCell.BackgrondColorProperty, "CellDefaultBackgroundColor"); + textCell.SetDynamicResource(TextCell.BackgroundColorProperty, "CellDefaultBackgroundColor"); } } else if (item is TemplateCell templateCell) { if (SelectableItems.Contains(templateCell.BindingContext)) { - templateCell.SetDynamicResource(TemplateCell.BackgrondColorProperty, "CellSelectedBackgroundColor"); + templateCell.SetDynamicResource(TemplateCell.BackgroundColorProperty, "CellSelectedBackgroundColor"); } else { - templateCell.SetDynamicResource(TemplateCell.BackgrondColorProperty, "CellDefaultBackgroundColor"); + templateCell.SetDynamicResource(TemplateCell.BackgroundColorProperty, "CellDefaultBackgroundColor"); } } } diff --git a/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml b/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml index 18c506d8..b689ae19 100644 --- a/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml +++ b/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml @@ -1,16 +1,21 @@  - - - - - - + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + x:Name="CustomViewCell" + xmlns:constant="clr-namespace:Trimble.Modus.Components.Constant" + x:Class="Trimble.Modus.Components.TemplateCell"> + + + + + + + + + diff --git a/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml.cs b/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml.cs index 9ae79326..fb6bf660 100644 --- a/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml.cs +++ b/Trimble.Modus.Components/Controls/ListView/TemplateCell.xaml.cs @@ -5,8 +5,8 @@ public partial class TemplateCell : ViewCell #region Bindable Properties public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(TemplateCell)); - public static readonly BindableProperty BackgrondColorProperty = - BindableProperty.Create(nameof(BackgrondColor), typeof(Color), typeof(TextCell), Colors.White, + public static readonly BindableProperty BackgroundColorProperty = + BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(TextCell), Colors.White, propertyChanged: OnBackgroundColorChanged); public View Content @@ -14,10 +14,10 @@ public View Content get => (View)GetValue(ContentProperty); set => SetValue(ContentProperty, value); } - public Color BackgrondColor + public Color BackgroundColor { - get => (Color)GetValue(BackgrondColorProperty); - set => SetValue(BackgrondColorProperty, value); + get => (Color)GetValue(BackgroundColorProperty); + set => SetValue(BackgroundColorProperty, value); } #endregion @@ -25,6 +25,8 @@ public Color BackgrondColor public TemplateCell() { InitializeComponent(); + + grid.BackgroundColor = BackgroundColor; } #endregion #region Private Methods diff --git a/Trimble.Modus.Components/Controls/ListView/TextCell.xaml b/Trimble.Modus.Components/Controls/ListView/TextCell.xaml index eb366420..c1f1a0f7 100644 --- a/Trimble.Modus.Components/Controls/ListView/TextCell.xaml +++ b/Trimble.Modus.Components/Controls/ListView/TextCell.xaml @@ -1,42 +1,61 @@  - - - - - - - + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + xmlns:converters="clr-namespace:Trimble.Modus.Components.Converters" + xmlns:constant="clr-namespace:Trimble.Modus.Components.Constant" + xmlns:helpers="clr-namespace:Trimble.Modus.Components.Helpers" + xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" + x:Name="textCell" + x:Class="Trimble.Modus.Components.TextCell"> + + + + + + + - - - - - - - - + - + - - - - + + + + diff --git a/Trimble.Modus.Components/Controls/ListView/TextCell.xaml.cs b/Trimble.Modus.Components/Controls/ListView/TextCell.xaml.cs index 32272d84..1bb57ac2 100644 --- a/Trimble.Modus.Components/Controls/ListView/TextCell.xaml.cs +++ b/Trimble.Modus.Components/Controls/ListView/TextCell.xaml.cs @@ -1,7 +1,7 @@ namespace Trimble.Modus.Components; public partial class TextCell : ViewCell -{ +{ #region Bindable Properties public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(TextCell), default(string)); @@ -15,9 +15,8 @@ public partial class TextCell : ViewCell public static readonly BindableProperty DescriptionProperty = BindableProperty.Create(nameof(Description), typeof(string), typeof(TextCell), default(string)); - public static readonly BindableProperty BackgrondColorProperty = - BindableProperty.Create(nameof(BackgrondColor), typeof(Color), typeof(TextCell), Colors.White, - propertyChanged: OnBackgroundColorChanged); + public static readonly BindableProperty BackgroundColorProperty = + BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(TextCell), Colors.White, propertyChanged: OnBackgroundColorChanged); #endregion #region Public Fields @@ -37,10 +36,10 @@ public string Title get => (string)GetValue(TitleProperty); set => SetValue(TitleProperty, value); } - public Color BackgrondColor + public Color BackgroundColor { - get => (Color)GetValue(BackgrondColorProperty); - set => SetValue(BackgrondColorProperty, value); + get => (Color)GetValue(BackgroundColorProperty); + set => SetValue(BackgroundColorProperty, value); } public string Description { @@ -53,16 +52,26 @@ public string Description public TextCell() { InitializeComponent(); + if (DeviceInfo.Platform != DevicePlatform.WinUI) + { + UpdateBackgroundColor(); + } } #endregion #region Private Methods + private static void OnBackgroundColorChanged(BindableObject bindable, object oldValue, object newValue) { - if (bindable!=null && bindable is TextCell cell) + if (bindable != null && bindable is TextCell cell) { - cell.grid.BackgroundColor = (Color)newValue; + cell.UpdateBackgroundColor(); } } + + private void UpdateBackgroundColor() + { + grid.BackgroundColor = BackgroundColor; + } #endregion } diff --git a/Trimble.Modus.Components/Styles/DarkTheme.xaml b/Trimble.Modus.Components/Styles/DarkTheme.xaml index 0efffda6..c2572906 100644 --- a/Trimble.Modus.Components/Styles/DarkTheme.xaml +++ b/Trimble.Modus.Components/Styles/DarkTheme.xaml @@ -206,7 +206,8 @@ #171C1E #4D019AEB - + #CBCDD6 + indeterminate_checkbox_dark.png checked_checkbox_dark.png diff --git a/Trimble.Modus.Components/Styles/LightTheme.xaml b/Trimble.Modus.Components/Styles/LightTheme.xaml index 87a662bc..ab0f013a 100644 --- a/Trimble.Modus.Components/Styles/LightTheme.xaml +++ b/Trimble.Modus.Components/Styles/LightTheme.xaml @@ -206,7 +206,8 @@ #FFFFFF #DCEDF9 - + #CBCDD6 + indeterminate_checkbox.png checked_checkbox.png