1

当我在 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)
    {}

xml代码

<phone:LongListSelector FontSize="50" Foreground="Gray" Tap="LongListSelector_Tap_1" ItemsSource="{Binding}" Margin="0,77,0,0" />
4

2 回答 2

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;
        }
于 2013-07-15T08:26:19.013 回答
0

你所要做的只是将你的按钮的可见性设置为可见,就像假设你的按钮名称是“Mybutton”..

private void LongListSelector_Tap_1(object sender,GestureEventArgs e)
{
  Mybutton.Visibility = Visibility.visible;
}
于 2013-07-15T08:24:28.837 回答