diff --git a/demo/Ursa.Demo/Pages/TimelineDemo.axaml b/demo/Ursa.Demo/Pages/TimelineDemo.axaml index 4761739..fcf8af2 100644 --- a/demo/Ursa.Demo/Pages/TimelineDemo.axaml +++ b/demo/Ursa.Demo/Pages/TimelineDemo.axaml @@ -80,6 +80,7 @@ Content="Step 5" Header="第五步" Mode="Separate" + TimeFormat="yyyy-MM-dd" Type="Error" /> diff --git a/src/Ursa/Controls/Timeline/Timeline.cs b/src/Ursa/Controls/Timeline/Timeline.cs index 467237f..811911b 100644 --- a/src/Ursa/Controls/Timeline/Timeline.cs +++ b/src/Ursa/Controls/Timeline/Timeline.cs @@ -150,10 +150,11 @@ public class Timeline: ItemsControl { t.Bind(TimelineItem.TimeProperty, TimeMemberBinding); } - t.SetCurrentValue(TimelineItem.TimeFormatProperty, TimeFormat); - t.SetCurrentValue(TimelineItem.IconTemplateProperty, IconTemplate); - t.SetCurrentValue(HeaderedContentControl.HeaderTemplateProperty, ItemTemplate); - t.SetCurrentValue(ContentControl.ContentTemplateProperty, DescriptionTemplate); + + t.SetIfUnset(TimelineItem.TimeFormatProperty, TimeFormat); + t.SetIfUnset(TimelineItem.IconTemplateProperty, IconTemplate); + t.SetIfUnset(HeaderedContentControl.HeaderTemplateProperty, ItemTemplate); + t.SetIfUnset(ContentControl.ContentTemplateProperty, DescriptionTemplate); } } diff --git a/src/Ursa/Controls/Timeline/TimelineItem.cs b/src/Ursa/Controls/Timeline/TimelineItem.cs index 2d6b8aa..0e591f7 100644 --- a/src/Ursa/Controls/Timeline/TimelineItem.cs +++ b/src/Ursa/Controls/Timeline/TimelineItem.cs @@ -190,4 +190,12 @@ public class TimelineItem: HeaderedContentControl _rootGrid.ColumnDefinitions[1].Width = new GridLength(mid??0); _rootGrid.ColumnDefinitions[2].Width = new GridLength(right??0); } + + internal void SetIfUnset(AvaloniaProperty property, T value) + { + if (!IsSet(property)) + { + SetCurrentValue(property, value); + } + } } \ No newline at end of file