0

いくつかのテキストブロックがあるユーザー コントロールがあります。このユーザーコントロールをリストボックス(または問題が発生した場合はリストビュー)に含めたいと思います。

出力ウィンドウを確認すると、バインド例外は表示されませんが、テキストブロックにも何も表示されません。

とにかくこれを機能させる方法はありますか?

ありがとう :

これが私が今使っているlistBoxです:

<ListBox AllowDrop="True"  Grid.Row="1" 
         Style="{StaticResource BaseListBox}" x:Name="LstEquipeDefaut">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <my:ucEquipe x:Name="ucEquipe" Grid.Row="1" Margin="5,0,5,2"/>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

ユーザーコントロールは次のとおりです。

<UserControl x:Class="ucEquipe"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
         mc:Ignorable="d"       
         d:DesignHeight="350" d:DesignWidth="180" MinWidth="180" >
<Border Style="{StaticResource UControlBorder}">
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="32" />
            <RowDefinition Height="25" />
            <RowDefinition Height="35" />
            <RowDefinition Height="100" />
            <RowDefinition Height="35" />
            <RowDefinition Height="100" />
        </Grid.RowDefinitions>

        <TextBox AllowDrop="True" x:Name="TxtChiefEquipe" 
                 Style="{StaticResource BaseTextBox}" 
                 Text="{Binding Mode=OneWay,Path=chefEquipe.NomComplet}" 
                 Grid.Row="1"  />           
    </Grid>
</Border>

私が使用するオブジェクトは次のとおりです。

Public Class Equipe

Public Property ID As Long = 0
Public Property Couleur As String = ""
Public Property Semaine As New Date(1900, 1, 1)
Public Property chefEquipe As Employe = Nothing

Public Property ListEquipeEmploye As New List(Of EquipeEmploye)
Public Property ListEquipeEquipement As New List(Of EquipeEquipement)

End Class

オブジェクト Employee には、NomComplet というプロパティがあります。とりあえず、テスト用にリストボックスに新しいオブジェクトを手動で追加しました。

4

1 に答える 1

1

あなたのEquipeクラスは実装する必要がありますINotifyPropertyChanged

private Employe _chefEquipe;
public Employe ChefEquipe
{
    get { retun _chefEquipe; }
    set 
    {
        _chefEquipe = value;
        NotifyPropertyChanged("ChefEquipe");
    }
}

C# については申し訳ありませんが、VB の構文はもう覚えていません =)

于 2013-04-09T18:04:57.927 に答える