0

e.Result として listbox.itemsource を使用していました。

<ListBox Height="476" HorizontalAlignment="Left" Margin="11,17,0,0" Name="ListBox1" VerticalAlignment="Top" Width="434" Foreground="#FFF5F5F1" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
<StackPanel Orientation="Vertical">
                            <TextBlock Height="40" HorizontalAlignment="Left" Margin="8,24,10,0" Name="txtBlockCustName" Text="{Binding CustName, Mode=OneWay}" VerticalAlignment="Top" FontSize="26" />

                            <TextBlock Height="40" HorizontalAlignment="Left" Margin="8,24,0,0" Name="txtBlockCustEmail" Text="{Binding CustEmail, Mode=OneWay}" VerticalAlignment="Top" FontSize="26" />
  </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

どうすればデータバインディング値を取得できますか?

void proxy_FindProfileCompleted(object sender, FindProfileCompletedEventArgs e)
        {
            ListBox1.ItemsSource = e.Result;
            ObservableCollection<Customer> Customers = this.ListBox1.ItemsSource as ObservableCollection<Customer>;
        }

監視可能なコレクションから顧客名と顧客の電子メールを取得したいと考えています。

4

2 に答える 2

1

これが必要かどうかわかりませんが、試してみてください:

void proxy_FindProfileCompleted(object sender, FindProfileCompletedEventArgs e)
{             
    ListBox1.ItemsSource = e.Result;
    ObservableCollection<Customer> Customers = 
        this.ListBox1.ItemsSource as ObservableCollection<Customer>;  
    foreach(Customer cust in Customers)
    {
        // You can get cust.CustName
        // and you can get cust.CustEmail
    }
}
于 2012-06-19T16:43:18.087 に答える
0

あなたはクラスを見ることから始めることができCollectionViewSourceます。これにより、現在のアイテムが追跡されます(IsSynchronizedWithCurrentItem=trueリストボックスのバインドが必要になる場合があります)。代わりにこれにバインドして渡すことができます。

これで質問に答えられない場合は、より詳細な例を考えてみます。

于 2012-06-19T16:47:23.703 に答える