SfPopupLayout popupLayout = new SfPopupLayout(); ContentView view = new ContentView() { Content = new Button() }; popupLayout.Content = view; popupLayout.Show(this.Content);
When i change to
popupLayout.Show();
the Popup is not shown.
Regards Michael
|
SfPopupLayout popupLayout;
public MainPage()
{
ContentView contentView = new ContentView();
Button clickToShowPopup = new Button();
clickToShowPopup.Text = "Click to show popup";
clickToShowPopup.Clicked += ClickToShowPopup_Clicked;
contentView.Content = clickToShowPopup;
popupLayout = new SfPopupLayout();
this.Content = contentView;
}
private void ClickToShowPopup_Clicked(object sender, EventArgs e)
{
popupLayout.Show(this.Content);
} |
|
//MainPage.Xaml.cs
var popupLayout = new SfPopupLayout();
popupLayout.BindingContext= new ViewModel();
var label = new Label();
label.TextColor = Color.Black;
label.HorizontalTextAlignment = TextAlignment.Center;
label.VerticalTextAlignment = TextAlignment.Center;
label.SetBinding(Label.TextProperty, new Binding() { Path = "Name", Source = popupLayout.BindingContext});
//ViewModel class
public class ViewModel : INotifyPropertyChanged
{
public ViewModel()
{
SetRow();
}
private string _name;
public event PropertyChangedEventHandler PropertyChanged;
public string Name
{
get { return _name; }
set
{
_name = value;
RaisePropertyChanged("Name");
}
}
internal void SetRow()
{
Name = "MyLabel";
}
private void RaisePropertyChanged(string name)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(name));
}
} |