私は数秒ごとに参加者の新しい ObservableCollection を取得します - ビューの取得はすべて正常に更新されます.秒)必要なアイテムを選択します(強調表示します)が、機能しません。選択をクリアします/ SelectedParticipant が設定された後、選択/強調表示が表示されません
- はい、もちろん、SelectedParticipant が null ではないことを確認しました
- LayoutUpdate() またはそのようなものを試しました
- SelectedItem="{Binding SelectedParticipant, Mode=TwoWay}" 内で UpdateSourceTrigger=PropertyChanged を試しました
ありがとう
private Participant _selectedParticipant;
public Participant SelectedParticipant
{
get
{
return _selectedParticipant;
}
set
{
if (_selectedParticipant != value)
{
_selectedParticipant = value;
RaisePropertyChanged("SelectedParticipant");
}
}
}
private ObservableCollection<Participant> _participants;
public ObservableCollection<Participant> Participants
{
get
{
return _participants;
}
set
{
if (_participants != value)
{
_participants = value;
RaisePropertyChanged("Participants");
if (_participants != null && _participants.Count > 0)
{
SelectedParticipant = null;
SelectedParticipant = Participants.FirstOrDefault(x => ... );
}
}
}
}
<ListBox ItemsSource="{Binding Participants}"
SelectedItem="{Binding SelectedParticipant, Mode=TwoWay}"
ItemContainerStyle="{StaticResource RedGlowItemContainer}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Background="Transparent"
Padding="25">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderThickness="6" >
<Grid>
<Image Source="{Binding Client.ImageURL}" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Fill" Width="128" Height="128"/>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>