English 中文(简体)
WP7 列入周转基金结果的装订清单箱
原标题:WP7 Binding Listbox to WCF result

我有一份WCF呼吁归还一份物体清单。

我发明了WP7银星号申请,并修改了主文Model,以装载我WCF服务的数据,现在,LoadData方法就是这样。

public ObservableCollection<Standing> Items { get; private set; }

public void LoadData()
{
    var c = new WS.WSClient();
    c.GetStandingsCompleted += GetStandingsCompleted;
    c.GetStandingsAsync();            
}

void GetStandingsCompleted(object sender, GetStandingsCompletedEventArgs e)
{
    Items = e.Result;
    this.IsDataLoaded = true;
}

如果我对已完成的活动提出突破点,我可以看到它成功,我的物品收集现在有50个奇题。 但是,国际不动产公司清单箱显示了这一点。

如果我把以下一线添加到我的LoadData方法的底线,那么,我看一看一个项目出现在ID的名单上。

Items.Add(new Standing(){Team="Test"});

这证明这些约束是正确的,但似乎由于阿森吉克妇女论坛的拖延,所以“国际倡议”没有更新。

参考I 更新了主Page.xaml清单箱,以约束小组在我的常备物体上的财产。

<ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}">
    <ListBox.ItemTemplate>
        <DataTemplate>
          <StackPanel Margin="0,0,0,17" Width="432">
                <TextBlock Text="{Binding Team}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                <TextBlock Text="{Binding Team}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
          </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

任何关于我做什么错误的想法?

增 编

最佳回答

当您的<代码>ListBox首先创建时,其代码为 财产现值。 项目,<编码>。 当您的WCF打电话完成并给您分配新价值>项目时,该观点根本无法知道,未经你发射,该财产的价值已发生变化。 PropertyChanged activity,如Greg Zimmers在其答复中提及的。

由于你重新使用<条码>可操作的Collection,一种替代办法是,首先建立一个空洞的收集,然后在WCF打电话填写时添加物体。

private ObservableCollection<Standing> _items = new ObservableCollection<Standing>();
public ObservableCollection<Standing> Items
{ 
  get { return _items; } 
  private set;
}


void GetStandingsCompleted(object sender, GetStandingsCompletedEventArgs e)
{
    foreach( var item in e.Result ) Items.Add( item );
    this.IsDataLoaded = true;
}
问题回答

Does your data entity "Standing" implement the INotifyPropertyChanged interface and do you raise the property changed event?





相关问题
How to bind a TabControl to an ObservableCollection in XAML

I have the following line of code in my code-behind class. TabControl.ItemsSource = ((MainWindowViewModel)DataContext).TabItemViewModels; I would like to move this to the XAML file. In brief, ...

Bind to ancestor of adorned element

Here is the case: <DataTemplate x:Key="ItemTemplate" DataType="local:RoutedCustomCommand"> <Button Command="{Binding}" Content="{Binding Text}" ...

LINQ to SQL as databinding source for WPF Treeview

I wonder if someone could provide a simple example of the following. (preferably in VB.Net): I have an SQL database with related tables and I am successfully using LINQ to SQL in other areas of my ...

Qt equivalent of .NET data binding?

Is there an equivalent of .NET s data binding in Qt? I want to populate some combo boxes and other widgets with QStrings that refer to specific entities in my database. However, it would be cleaner ...

WPF TreeView binding through XAML

So I have a class structure like this Store Owner Cashier List of Products Product Name Price List of Vendors Company Name Contact Name So there are 4 ...

热门标签