From 0b7af420bb41ab391f3fc2cf9077300f99b0f2ae Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 24 Aug 2024 08:51:32 +0100 Subject: [PATCH 1/2] Tidy up viewlocator. --- SukiUI.Demo/Common/ViewLocator.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SukiUI.Demo/Common/ViewLocator.cs b/SukiUI.Demo/Common/ViewLocator.cs index c9d0a5302..4f12def8b 100644 --- a/SukiUI.Demo/Common/ViewLocator.cs +++ b/SukiUI.Demo/Common/ViewLocator.cs @@ -12,23 +12,23 @@ public class ViewLocator : IDataTemplate public Control Build(object? data) { - var fullName = data?.GetType().FullName; - if (fullName is null) - { - return new TextBlock { Text = "Data is null or has no name." }; - } + if(data is null) + return new TextBlock { Text = "Data is null." }; + + var fullName = data.GetType().FullName; + + if (string.IsNullOrWhiteSpace(fullName)) + return new TextBlock { Text = "Type has no name, or name is empty." }; var name = fullName.Replace("ViewModel", "View"); var type = Type.GetType(name); if (type is null) - { return new TextBlock { Text = $"No View For {name}." }; - } - if (!_controlCache.TryGetValue(data!, out var res)) + if (!_controlCache.TryGetValue(data, out var res)) { res ??= (Control)Activator.CreateInstance(type)!; - _controlCache[data!] = res; + _controlCache[data] = res; } res.DataContext = data; From 308682cb3c8aebc7517afc9b970867de8b7b5e72 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 24 Aug 2024 09:01:53 +0100 Subject: [PATCH 2/2] Add `HorizontalTabs` class to `TabControl` so labels are horizontal. A useful option for those that need it - Addresses #279 --- .../TabControl/TabControlView.axaml | 10 ++++++++++ SukiUI/Theme/TabControl.axaml | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/SukiUI.Demo/Features/ControlsLibrary/TabControl/TabControlView.axaml b/SukiUI.Demo/Features/ControlsLibrary/TabControl/TabControlView.axaml index 43e7673fd..d2d588e29 100644 --- a/SukiUI.Demo/Features/ControlsLibrary/TabControl/TabControlView.axaml +++ b/SukiUI.Demo/Features/ControlsLibrary/TabControl/TabControlView.axaml @@ -65,6 +65,16 @@ + + + + + + + + + + diff --git a/SukiUI/Theme/TabControl.axaml b/SukiUI/Theme/TabControl.axaml index a420bf404..49ac2c187 100644 --- a/SukiUI/Theme/TabControl.axaml +++ b/SukiUI/Theme/TabControl.axaml @@ -28,7 +28,7 @@ @@ -42,7 +42,24 @@ + + + + + + +