Rg.Plugins.Popup 如何在条目获得焦点时使弹出窗口显示在顶部
Rg.Plugins.Popup how to make the popup appear on top when an entry is given focus
我在弹出窗口中有两个条目,但是当我给它焦点并且键盘出现时,弹出窗口不显示,只有当你开始在条目中输入文本时它才会出现,当键盘关闭时它会显示不是 return 到它的初始位置
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
x:Class="MyApp.Views.RgPluginsPopup"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
<pages:PopupPage.Animation>
<animations:ScaleAnimation
DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8" />
</pages:PopupPage.Animation>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Frame
BackgroundColor="White"
CornerRadius="10"
HasShadow="False">
<StackLayout Spacing="20">
<Label
FontSize="16"
HorizontalOptions="Center"
Text="Please enter your credentials" />
<Entry Placeholder="Username" />
<Entry IsPassword="True" Placeholder="Password" />
<Button Text="Sign in" />
</StackLayout>
</Frame>
</StackLayout>
</pages:PopupPage>
经过我的测试,进入页面时设置焦点可以解决这个问题
这里是 xaml 代码:
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Frame
BackgroundColor="White"
CornerRadius="10"
HasShadow="False">
<StackLayout Spacing="20">
<Label
FontSize="16"
HorizontalOptions="Center"
Text="Please enter your credentials" />
<Entry Placeholder="Username" x:Name="test"/>
<Entry IsPassword="True" Placeholder="Password" />
<Button Text="Sign in" />
</StackLayout>
</Frame>
</StackLayout>
这里是背景代码:
public partial class Page1 : Rg.Plugins.Popup.Pages.PopupPage
{
public Page1()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
test.Focus();
}
}
我在弹出窗口中有两个条目,但是当我给它焦点并且键盘出现时,弹出窗口不显示,只有当你开始在条目中输入文本时它才会出现,当键盘关闭时它会显示不是 return 到它的初始位置
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
x:Class="MyApp.Views.RgPluginsPopup"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
<pages:PopupPage.Animation>
<animations:ScaleAnimation
DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8" />
</pages:PopupPage.Animation>
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Frame
BackgroundColor="White"
CornerRadius="10"
HasShadow="False">
<StackLayout Spacing="20">
<Label
FontSize="16"
HorizontalOptions="Center"
Text="Please enter your credentials" />
<Entry Placeholder="Username" />
<Entry IsPassword="True" Placeholder="Password" />
<Button Text="Sign in" />
</StackLayout>
</Frame>
</StackLayout>
</pages:PopupPage>
经过我的测试,进入页面时设置焦点可以解决这个问题
这里是 xaml 代码:
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Frame
BackgroundColor="White"
CornerRadius="10"
HasShadow="False">
<StackLayout Spacing="20">
<Label
FontSize="16"
HorizontalOptions="Center"
Text="Please enter your credentials" />
<Entry Placeholder="Username" x:Name="test"/>
<Entry IsPassword="True" Placeholder="Password" />
<Button Text="Sign in" />
</StackLayout>
</Frame>
</StackLayout>
这里是背景代码:
public partial class Page1 : Rg.Plugins.Popup.Pages.PopupPage
{
public Page1()
{
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
test.Focus();
}
}