SelectedItem of listbox - BindableCollection is binded on listbox
- by user572844
Hi, I bind BindableCollection from caliburn micro on listbox. Also I bind selected listbox item on property in view model. After I select some item on listbox, property SelectedFriedn which is bind on SelectedItem of listbox is still null.
Code from view model:
private BindableCollection<UserInfo> _friends;
//bind on listbox
public BindableCollection<UserInfo> Friends
{
get { return _friends; }
set
{
_friends = value;
NotifyOfPropertyChange(() => Friends);
}
}
private UserInfo _selectedFriend = new UserInfo();
//bind on SelectedItem property of listbox
public UserInfo SelectedFriend
{
get { return _selectedFriend; }
set
{
_selectedFriend = value;
NotifyOfPropertyChange(() => SelectedFriend);
}
}
In view I have this:
<ListBox Name="Friends"
SelectedIndex="{Binding Path=SelectedFriendsIndex,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding Path=SelectedFriend, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource friendsListStyle}"
IsTextSearchEnabled="True" TextSearch.TextPath="Nick"
Grid.Row="2"
Margin="4,4,4,4"
PreviewMouseRightButtonUp="ListBox_PreviewMouseRightButtonUp"
PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown"
MouseRightButtonDown="ListBox_MouseRightButtonDown"
Micro:Message.Attach="[MouseDoubleClick]=[Action OpenChatScreen()]" >
Where can be problem?