이 목록 상자에는 연락처 이름이 표시됩니다.바인딩 가능한 컬렉션의 항목 색인 가져 오기
<ListBox x:Name="Items" Margin="36,38,78,131">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="lol" Text="{Binding Path=ContactName}" Style="{StaticResource PhoneTextSmallStyle}"
Width="Auto" TextAlignment="Center" FontWeight="Bold" Foreground="White" VerticalAlignment="Bottom" TextWrapping="Wrap"/>
<Button x:Name="ShowName">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cal:ActionMessage MethodName="delete" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
은 내가 접촉하는 경우 그 버튼을 누르면 삭제할 수 있습니다
public List<FBContacts> listContactDatas { get; set; }
Items = new BindableCollection<FBContacts>();= new BindableCollection<FBContacts>();
public void GetContacts()
{
using(MyDataContext mydb = new MyDataContext(DBConnectionstring))
{
var items = from ContactsList Name in mydb._contacts select Name;
foreach (var toDoItem in items)
{
Items.Add(new FBContacts()
{
ContactName = toDoItem.Name
});
}
}
}
사용자 로컬 DB에서 연락처를 얻을.
public void delete()
{
Items.RemoveAt(/* index*/);
}
어떻게 연락처를 선택할 수 있습니까? 별도의 재산
선택 항목을 변경할 때'SelectedListIndex' 속성이 업데이트됩니까 (예 : Setter의 중단 점)? 어쩌면 당신은'SelectedIndex = "{SelectedListIndex, Mode = TwoWay}"속성 업데이트를 강제로 추가 할 필요가 있습니다. – andreask
이 오류가 발생합니다 System.Windows.ni.dll에서 –
아마도 목록의 선택은 다음과 같습니다. 'SelectedListIndex'가 생성되기 전에 변경된 사항 목록을 채우는 방법 목록 항목은 데이터 바인딩을 통해 설정되어 있습니까? – andreask