Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 3.0 BusyIndicator.Message绑定到字符串集合_Silverlight 3.0_Toolkit_Busyindicator - Fatal编程技术网

Silverlight 3.0 BusyIndicator.Message绑定到字符串集合

Silverlight 3.0 BusyIndicator.Message绑定到字符串集合,silverlight-3.0,toolkit,busyindicator,Silverlight 3.0,Toolkit,Busyindicator,我正在尝试将SL BusyIndicator绑定到繁忙消息的集合。当集合包含项目时,指示器将显示消息。当消息集合为空时,指示器将隐藏 首先,指示器没有显示我的消息,我看到的只是一个空白的指示器框,带有一个不确定的进度条: <UserControl.Resources> ... <anotherAssembly:CollectionToBoolConverter x:Key="CollectionToBoolConverter" /> <DataTemplate

我正在尝试将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");
        }
    }
private observedcollection\u allocationLoadingMessages=new observedcollection();
公共可观测集合分配加载消息
{
获取{return}allocationLoadingMessages;}
设置
{
设置值(参考分配加载消息,值,“分配加载消息”);
}
}
那么,如何在指示器中获得简单的消息列表呢

谢谢,

标记

您的代码非常接近目标,要使其正常工作,只需替换该行即可

<ItemsControl x:Name="itemsControl" ItemsSource="{Binding AllocationLoadingMessages}" >

很抱歉我迟到了(直到现在才遇到这个问题),但我希望它至少能帮助其他正在寻找答案的人。

Visual Studio是否在抱怨输出窗口中运行时存在绑定错误?输出窗口中没有绑定错误。好的建议,谢谢你的及时回复。还在用这个砸我的头!
<ItemsControl x:Name="itemsControl" ItemsSource="{Binding}" >
    public ObservableCollection<string> AllocationLoadingMessages { get; set; }

    private int _loadingMessageNumber = 0;
    private void Add()
    {
        AllocationLoadingMessages.Add( "Loading message #" + ++_loadingMessageNumber );
        PropertyChanged( this, new PropertyChangedEventArgs( "AllocationLoadingMessages" ) );
    }

    private void RemoveFirst()
    {
        if( AllocationLoadingMessages.Count > 0 )
        {
            AllocationLoadingMessages.RemoveAt( 0 );
            PropertyChanged( this, new PropertyChangedEventArgs( "AllocationLoadingMessages" ) );
        }
    }