我正在尝试将 SL BusyIndicator 绑定到繁忙消息的集合。当集合有项目时,指示器将显示消息。当消息集合为空时,指示器将隐藏。
首先,指示器没有显示我的消息,我看到的只是一个空白指示器框,带有一个不确定的进度条:
<UserControl.Resources>
...
<anotherAssembly:CollectionToBoolConverter x:Key="CollectionToBoolConverter" />
<DataTemplate x:Key="LoadingMessageDataTemplate">
<ItemsControl x:Name="itemsControl" ItemsSource="{Binding AllocationLoadingMessages}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
...
</UserControl.Resources>
...
<controlToolkit:BusyIndicator
IsBusy="{Binding AllocationLoadingMessages, Converter={StaticResource CollectionToBoolConverter}}"
BusyContent="{Binding AllocationLoadingMessages}"
BusyContentTemplate="{StaticResource LoadingMessageDataTemplate}"/>
///content
</controlToolkit:BusyIndicator>
...
视图模型:
private ObservableCollection<string> _allocationLoadingMessages = new ObservableCollection<string>();
public ObservableCollection<string> AllocationLoadingMessages
{
get { return _allocationLoadingMessages; }
set
{
SetValue(ref _allocationLoadingMessages, value, "AllocationLoadingMessages");
}
}
那么如何在我的指标中获得一个简单的消息列表呢?
谢谢,
马克