当我在Windows Phone 8中点击长列表选择器时,我想显示一个按钮。
C#
this.DisplayedContacts = new ObservableCollection<string>();
this.DataContext = this.DisplayedContacts;
var contacts = new Contacts();
contacts.SearchCompleted += (s, e) =>
{
foreach (var contact in e.Results)
{
Debug.WriteLine(contact.PhoneNumbers.Any()? contact.PhoneNumbers.First().PhoneNumber: string.Empty);
this.DisplayedContacts.Add(contact.DisplayName + " - " +
(contact.PhoneNumbers.Any()
? contact.PhoneNumbers.First().PhoneNumber
: string.Empty));
}
};
contacts.SearchAsync(string.Empty, FilterKind.DisplayName, null);
}
public ObservableCollection<string> DisplayedContacts { get; set; }
private void LongListSelector_Tap_1(object sender,GestureEventArgs e)
{}
xaml代码
<phone:LongListSelector FontSize="50" Foreground="Gray" Tap="LongListSelector_Tap_1" ItemsSource="{Binding}" Margin="0,77,0,0" />
答案 0 :(得分:1)
用户Visibility
属性可隐藏您的列表并显示Button
。
你的XAML
看起来就像是吼叫:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" >
<phone:LongListSelector x:Name="LongList" Tap="LongListTap"/>
<Button x:Name="ActionButton" Visibility="Collapsed"/>
</Grid>
事件处理程序:
private void LongListTap(object sender, GestureEventArgs e)
{
LongList.Visibility = Visibility.Collapsed;
ActionButton.Visibility = Visibility.Visible;
}
答案 1 :(得分:0)
你所拥有的只是将你的按钮的可见性设置为可见,就像假设你的按钮名称是“Mybutton”..
private void LongListSelector_Tap_1(object sender,GestureEventArgs e)
{
Mybutton.Visibility = Visibility.visible;
}