【发布时间】:2011-01-03 00:15:15
【问题描述】:
我正在尝试将 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");
}
}
那么如何在我的指标中获得一个简单的消息列表?
谢谢,
标记
【问题讨论】:
-
Visual Studio 是否在抱怨输出窗口在运行时出现绑定错误?
-
输出窗口中没有绑定错误。很好的建议,无论如何感谢您的及时回复。仍然在这个问题上抨击我!
标签: silverlight-3.0 toolkit busyindicator