|
<sfPopup:SfPopupLayout x:Name="popupLayout">
<sfPopup:SfPopupLayout.PopupView>
<sfPopup:PopupView WidthRequest="220" HeightRequest="120" ShowFooter="False">
<sfPopup:PopupView.ContentTemplate>
<DataTemplate>
<Label Text="Button tapped" BackgroundColor="White" TextColor="Black" HorizontalTextAlignment="Center"/>
</DataTemplate>
</sfPopup:PopupView.ContentTemplate>
</sfPopup:PopupView>
</sfPopup:SfPopupLayout.PopupView>
<sfPopup:SfPopupLayout.Content>
<syncfusion:SfListView x:Name="listView" ItemSize="60" ItemsSource="{Binding ContactsInfo}">
<syncfusion:SfListView.ItemTemplate >
<DataTemplate>
<Grid x:Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="{Binding ContactImage}" VerticalOptions="Center" HorizontalOptions="Center" HeightRequest="50" WidthRequest="50"/>
<Grid Grid.Column="1" RowSpacing="1" Padding="10,0,0,0" VerticalOptions="Center">
<Label LineBreakMode="NoWrap" TextColor="#474747" Text="{Binding ContactName}"/>
<Label Grid.Row="1" Grid.Column="0" TextColor="#474747" LineBreakMode="NoWrap" Text="{Binding ContactNumber}"/>
<Button Text="Button" Clicked="Button_Clicked" HorizontalOptions="End"/>
</Grid>
</Grid>
</DataTemplate>
</syncfusion:SfListView.ItemTemplate>
</syncfusion:SfListView>
</sfPopup:SfPopupLayout.Content>
</sfPopup:SfPopupLayout> |
|
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
popupLayout.Show();
}
} |
|
private void InitializePopupContent()
{
var sfListView = new SfListView() { ItemSize = 50 };
var viewModel = new ContactsViewModel();
sfListView.ItemsSource = viewModel.ContactsInfo;
sfListView.ItemTemplate = new DataTemplate(() => {
var grid = new Grid();
var contactName = new Label { FontAttributes = FontAttributes.Bold, FontSize = 21 };
contactName.SetBinding(Label.TextProperty, new Binding("ContactName"));
var showButton = new Button() { Text = "Show popup" };
showButton.Clicked += (sender, args) =>
{
var item = (sender as Button).BindingContext as Contacts;
popupLayout.PopupView.BindingContext = item;
popupLayout.Show();
};
grid.Children.Add(contactName);
grid.Children.Add(showButton, 1, 0);
return grid;
});
popupLayout.Content = sfListView;
} |