SelectedItem of listbox - BindableCollection is binded on listbox
Posted
by
user572844
on Stack Overflow
See other posts from Stack Overflow
or by user572844
Published on 2011-01-16T17:48:43Z
Indexed on
2011/01/16
17:53 UTC
Read the original article
Hit count: 582
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?
© Stack Overflow or respective owner