I have a sample Xamarin Forms app (source located on GitHub here) where I need the dialog that pops when you click the button to center itself on the screen. Instead it is centering in its parent.
I read you can center a Popup by attaching it to the page level. And that works fine. But the BindingContext for the popup can't be set in this way.
Our app uses a ContentPage that is comprised of a bunch of ContentViews. And the ContentViews are the things that define the various popup dialogs (not the ContentPage). Furthermore, the BindingContext is set at the ContentView level. You can see an example of this in the code example I provided in the repo.
The repo defines a MainPage.xaml which hosts a ParentView which hosts a PopupView. It should be easy to follow the structure.
How can this sample be changed to show the dialog in the center of the screen?
I am using FreshMVVM and am having trouble getting a simple popup example to work.
For my View I have...
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?> <
ContentPage
xmlns
=
"http://xamarin.com/schemas/2014/forms"
xmlns:telerikPrimitives
=
"clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
xmlns:x
=
"http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local
=
"clr-namespace:SampleApp"
x:Class
=
"SampleApp.MainPage"
>
<
StackLayout
> <
telerikPrimitives:RadPopup.Popup
> <
telerikPrimitives:RadPopup
IsOpen
=
"{Binding Dialog1Open}"
> <
Label
Text
=
"Dialog 1"
/> </
telerikPrimitives:RadPopup
> </
telerikPrimitives:RadPopup.Popup
>
<
telerikPrimitives:RadPopup.Popup
> <
telerikPrimitives:RadPopup
IsOpen
=
"{Binding Dialog2Open}"
> <
Label
Text
=
"Dialog 2"
/> </
telerikPrimitives:RadPopup
> </
telerikPrimitives:RadPopup.Popup
>
<
Button
Text
=
"Open Dialog 1"
Command
=
"{Binding OpenDialog1}"
/> <
Button
Text
=
"Open Dialog 2"
Command
=
"{Binding OpenDialog2}"
/>
</
StackLayout
>
</
ContentPage
>
and the ViewModel I have...
public class MainPageModel : FreshBasePageModel {
public bool Dialog1Open { get; set; }
public bool Dialog2Open { get; set; }
public ICommand OpenDialog1
{
get {
return new Command(() => { Dialog1Open = true; });
}
}
public ICommand OpenDialog2
{
get {
return new Command(() => { Dialog2Open = true; });
}
}
}
How would this code be changed to make my example work?
The complete source for my example can be found at...
https://github.com/JohnLivermore/SampleXamarinApp/tree/telerikpopupexample
I have a Forms app using RadPopup
var preview =
new
RadPopup();
preview.IsModal =
true
;
preview.Placement = PlacementMode.Center;
preview.PlacementTarget = overlay;
var containerGrid =
new
Grid { Padding = 10 };
// populate grid here
preview.Content = containerGrid;
preview.IsOpen =
true
;
this works great on Android. On iOS nothing happens. The popup does not display, and I don't see any errors, exceptions or console messages.
Any suggestions on what might be wrong, or how I can go about debugging this?
Telerik 2019.1.318.1
XF 3.6.0.344457
iOS 12.2
I would like to mimic the style of display aleart found in andriod and ios sdk for a input dialog i have so far. But i do not no how to set the height and the width of the popup.
But its not quite their as you will see with the screen grab.
![](https://i.imgur.com/mRQ2YKm.png)
Also how would one allow the keyboard to dismiss the window. uppon clicking the keyboard return?.
01.
<telerikPrimitives:RadPopup.Popup>
02.
<telerikPrimitives:RadPopup x:Name=
"popupQty"
03.
IsModal=
"True"
04.
Placement=
"Center"
05.
06.
OutsideBackgroundColor=
"#B3FFF493"
>
07.
<telerikPrimitives:RadBorder
08.
CornerRadius=
"6"
09.
BackgroundColor=
"#93D7FF"
10.
Padding=
"10"
>
11.
<Grid>
12.
<Grid.RowDefinitions>
13.
<RowDefinition Height=
"100"
/>
14.
<RowDefinition Height=
"100"
/>
15.
</Grid.RowDefinitions>
16.
<Label Text=
"Please enter qty"
></Label>
17.
<telerikInput:RadEntry x:Name=
"txtQty"
/>
18.
19.
20.
21.
<Button Grid.Row=
"1"
22.
Padding=
"2"
23.
HorizontalOptions=
"Center"
24.
Text=
"Close"
25.
26.
CornerRadius=
"6"
27.
BackgroundColor=
"#7A9BFF"
28.
TextColor=
"White"
/>
29.
</Grid>
30.
</telerikPrimitives:RadBorder>
31.
</telerikPrimitives:RadPopup>
32.
</telerikPrimitives:RadPopup.Popup>
Hi,
I am playing around with the PopUp but I have several basic issues:
Best regards,
Hi,
I have a Picker inside a Popup. I want to open the picker from the code. Usually I would call ".Focus", but it gives an error:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer'.
(The same happens if I try to set focus to an Entry.)
Please help!
Best regards,
Michael