fix: Fix DatePicker initialization issue.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:viewModels="clr-namespace:Ursa.Demo.ViewModels"
|
||||
x:DataType="viewModels:DatePickerDemoViewModel"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Ursa.Demo.Pages.DatePickerDemo">
|
||||
<StackPanel Margin="20" HorizontalAlignment="Left">
|
||||
@@ -10,5 +12,9 @@
|
||||
<TextBlock Text="{Binding #singlePicker.SelectedDate}" ></TextBlock>
|
||||
<u:DatePicker Name="singlePicker" Width="200" Classes="ClearButton" />
|
||||
<u:DateRangePicker Width="300" DisplayFormat="yyyyMMdd" Classes="ClearButton" />
|
||||
|
||||
<TextBlock Text="Binding"></TextBlock>
|
||||
<u:DatePicker Width="200" SelectedDate="{Binding SelectedDate, Mode=TwoWay}"/>
|
||||
<u:DateRangePicker Width="300" SelectedStartDate="{Binding StartDate}" SelectedEndDate="{Binding EndDate}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,6 +1,28 @@
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
public class DatePickerDemoViewModel
|
||||
namespace Ursa.Demo.ViewModels;
|
||||
|
||||
public partial class DatePickerDemoViewModel: ObservableObject
|
||||
{
|
||||
|
||||
[ObservableProperty] private DateTime? _selectedDate;
|
||||
[ObservableProperty] private DateTime? _startDate;
|
||||
[ObservableProperty] private DateTime? _endDate;
|
||||
|
||||
public DatePickerDemoViewModel()
|
||||
{
|
||||
SelectedDate = DateTime.Today;
|
||||
StartDate = DateTime.Today;
|
||||
EndDate = DateTime.Today.AddDays(7);
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnPropertyChanged(e);
|
||||
if (e.PropertyName == nameof(SelectedDate))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user