diff --git a/demo/Ursa.Demo/Converters/TimelineIconConverter.cs b/demo/Ursa.Demo/Converters/TimelineIconConverter.cs
new file mode 100644
index 0000000..04d46f4
--- /dev/null
+++ b/demo/Ursa.Demo/Converters/TimelineIconConverter.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Globalization;
+using Avalonia;
+using Avalonia.Data;
+using Avalonia.Data.Converters;
+using Avalonia.Media;
+using Ursa.Controls;
+
+namespace Ursa.Demo.Converters;
+
+public class TimelineIconConverter: IValueConverter
+{
+ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (value is TimelineItemType t)
+ {
+ return t switch
+ {
+ TimelineItemType.Success => Brushes.Green,
+ TimelineItemType.Ongoing => Brushes.Blue,
+ TimelineItemType.Error => Brushes.Red,
+ _ => Brushes.Gray
+ };
+ }
+ return AvaloniaProperty.UnsetValue;
+ }
+
+ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/demo/Ursa.Demo/Pages/TimelineDemo.axaml b/demo/Ursa.Demo/Pages/TimelineDemo.axaml
index ad01c4f..1906f87 100644
--- a/demo/Ursa.Demo/Pages/TimelineDemo.axaml
+++ b/demo/Ursa.Demo/Pages/TimelineDemo.axaml
@@ -6,15 +6,29 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
+ xmlns:selectors="clr-namespace:Ursa.Demo.TemplateSelectors"
d:DesignHeight="450"
d:DesignWidth="800"
x:DataType="viewModels:TimelineDemoViewModel"
x:CompileBindings="True"
mc:Ignorable="d">
+
+
+
+
+
+
+
+
+
+
+
diff --git a/demo/Ursa.Demo/TemplateSelectors/TimelineIconTemplateSelector.cs b/demo/Ursa.Demo/TemplateSelectors/TimelineIconTemplateSelector.cs
new file mode 100644
index 0000000..ceba90a
--- /dev/null
+++ b/demo/Ursa.Demo/TemplateSelectors/TimelineIconTemplateSelector.cs
@@ -0,0 +1,30 @@
+using Avalonia.Controls;
+using Avalonia.Controls.Shapes;
+using Avalonia.Controls.Templates;
+using Avalonia.Media;
+using Ursa.Controls;
+
+namespace Ursa.Demo.TemplateSelectors;
+
+public class TimelineIconTemplateSelector: ResourceDictionary, IDataTemplate
+{
+
+ public Control? Build(object? param)
+ {
+ if (param is TimelineItemType t)
+ {
+ string s = t.ToString();
+ if (ContainsKey(s))
+ {
+ object? o = this[s];
+ if (o is Control c) return c;
+ }
+ }
+ return null;
+ }
+
+ public bool Match(object? data)
+ {
+ return data is TimelineItemType;
+ }
+}
\ No newline at end of file
diff --git a/demo/Ursa.Demo/ViewModels/TimelineDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/TimelineDemoViewModel.cs
index ece4543..73e1335 100644
--- a/demo/Ursa.Demo/ViewModels/TimelineDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/TimelineDemoViewModel.cs
@@ -22,7 +22,7 @@ public class TimelineDemoViewModel: ViewModelBase
TimeFormat = "HH:mm:ss",
Description = "Item 2",
Header = "发布成功",
- ItemType = TimelineItemType.Success,
+ ItemType = TimelineItemType.Ongoing,
},
new()
{
@@ -30,7 +30,7 @@ public class TimelineDemoViewModel: ViewModelBase
TimeFormat = "HH:mm:ss",
Description = "Item 3",
Header = "审核失败",
- ItemType = TimelineItemType.Ongoing,
+ ItemType = TimelineItemType.Error,
}
};
}
diff --git a/src/Ursa.Themes.Semi/Controls/Timeline.axaml b/src/Ursa.Themes.Semi/Controls/Timeline.axaml
index 759be18..7b192ce 100644
--- a/src/Ursa.Themes.Semi/Controls/Timeline.axaml
+++ b/src/Ursa.Themes.Semi/Controls/Timeline.axaml
@@ -50,14 +50,11 @@
Classes="start"
Fill="{DynamicResource TimelineLineBrush}" />
-
+ VerticalAlignment="Center"
+ ContentTemplate="{TemplateBinding IconTemplate}"/>