0
UI를 업데이트하는 동안 문제가 발생했습니다. 필요한 것은 BusyIndicator
을 표시 한 후 메시지를 변경하고 5 초가 지나면 2 초 동안 다른 메시지를 표시 한 다음 BusyIndicator
을 숨기는 것입니다. 고마워!WPF Toolkit BusyIndicator
XAML
<xctk:BusyIndicator IsBusy="{Binding IsBusy}" DisplayAfter="0">
<xctk:BusyIndicator.BusyContentTemplate>
<DataTemplate>
<StackPanel>
<mahApps:ProgressRing IsActive="{Binding IsBusy}"/>
<Label Content="{Binding ShowMessage}"/>
</StackPanel>
</DataTemplate>
</xctk:BusyIndicator.BusyContentTemplate>
...
</xctk:BusyIndicator>
XAML 뷰 모델
public string ShowMessage
{
get { return _showMessage; }
set
{
_showMessage = value;
RaisePropertyChanged("ShowMessage");
}
}
private void Save()
{
ShowMessage = "Wait please...";
Task.Factory.StartNew(() =>
{
IsBusy = true; // Show busyindicator and ProgressRing
Thread.Sleep(5000); // 5 seconds to see the animation (Here is a SQL insert)
/// Hide ProgressRing only
ShowMessage = "Save complete.";
Thread.Sleep(2000); // 2 seconds to see "ShowMessage"
}).ContinueWith(x =>
{
IsBusy = false; // hide busyindicator and ProgressRing
...
}, TaskScheduler.FromCurrentSynchronizationContext());
}