I get new ObservableCollection of Participants every few seconds - view gettings update all good, The problem is SelectedItem , SelectedParticipant is updated when you selected a item from the listbox , but not the other way , I want by logic ( after ObservableCollection is updated every few sec ) to select the item I wanna (highlight it) , but it doesn't work , its clear the selection / does't show selection/highlight after SelectedParticipant is set by me
- Yes , ofcouse I cheked SelectedParticipant is not null
- Tried LayoutUpdate() or something like that
- Tried UpdateSourceTrigger=PropertyChanged inside SelectedItem="{Binding SelectedParticipant, Mode=TwoWay}"
Thanks
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>