你好我是新手通过xamarin表单开发应用程序,我有一个有三个edittext的屏幕,当我点击客户端编辑文本时,它打开一个新的屏幕,其中有一个项目列表,每当我回去或点击一个项目之前屏幕上的按钮消失了。
以下是图片网址:
Button disappears on click of item or back
以下是完整的代码:
这是主要的添加订单文件
win = new BrowserWindow({
frame: false,
transparent: true,
});
html {
width: /* less then window's size */;
height: /* the same */;
background: /* some color here */
}
}
这是派对列表模型类:
public class AddOrderPageModel : BaseEntryPageModel
{
public AddOrderPageModel(OrderDataModel order, bool isEditable)
{
this.order = order;
this.isEditable = isEditable;
}
public string Client
{
get
{
return this.client;
}
set
{
if (this.client != value)
{
this.client = value;
this.OnPropertyChanged("Client");
}
}
}
public ICommand SearchClientCommand
{
get
{
return new Command(this.OnSearchClientCommand);
}
}
private void OnSearchClientCommand(object obj)
{
refreshOrder = false;
PartyListPageModel pageModel = new PartyListPageModel();
pageModel.PartySelected = this.ClientSelected;
NavigationHelper.PushOnMainNavigation(new PartyListPage(pageModel));
}
聚会列表页面xaml:
public PartyListPage(PartyListPageModel model)
{
try
{
this.BindingContext = model;
model.CurrentPage = this;
this.InitializeComponent();
this.Appearing += model.Init;
this.ListView.ItemSelected += model.OnItemSelected;
txtSearch.TextChanged += model.TxtSearch_TextChanged;
SetTapGestureEventToSearchImage();
}
catch (Exception) { throw; }
}
// And some methods
添加订单页面xaml:
<?xml version="1.0" encoding="UTF-8"?>
<basepage:BasePage
xmlns ="http://xamarin.com/schemas/2014/forms"
xmlns:x ="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class ="Biocorp.AppClasses.PagesAndViewModels.Party.PartyList.PartyListPage"
xmlns:basepage="clr-namespace:Biocorp.AppClasses.PagesAndViewModels.Base;assembly=Biocorp"
xmlns:i18n ="clr-namespace:Biocorp;assembly=Biocorp"
xmlns:rendered="clr-namespace:Biocorp.AppClasses.Rendered;assembly=Biocorp">
<ContentPage.Content>
<RelativeLayout
HorizontalOptions="Fill"
BackgroundColor ="White">
<RelativeLayout
VerticalOptions ="Fill"
HorizontalOptions="Fill">
<RelativeLayout.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="Android">50</On>
<On Platform="iOS">100</On>
</OnPlatform>
</RelativeLayout.HeightRequest>
<rendered:BaseButton
IsEnabled ="false"
Text =""
BackgroundColor ="White"
BorderRadius ="2"
BorderWidth ="1"
RelativeLayout.XConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0, Constant=5}"
RelativeLayout.YConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=5}"
RelativeLayout.WidthConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-10}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-10}" />
<StackLayout
Orientation ="Horizontal"
Spacing ="5"
RelativeLayout.XConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0, Constant=5}"
RelativeLayout.YConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=5}"
RelativeLayout.WidthConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-10}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-10}">
<StackLayout
Orientation ="Vertical"
Spacing ="0"
Padding ="0,0,0,0"
VerticalOptions ="Fill"
HorizontalOptions="End"
WidthRequest ="40">
<Image
Source ="ic_back"
Aspect ="AspectFit"
WidthRequest ="15"
HeightRequest ="15"
VerticalOptions ="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding BackCommand}" />
</StackLayout.GestureRecognizers>
</StackLayout>
<StackLayout
Orientation ="Vertical"
Spacing ="0"
Padding ="5,5,15,0"
VerticalOptions ="Fill"
HorizontalOptions="FillAndExpand">
<rendered:BaseEntry
Text ="{Binding SearchText}"
x:Name ="txtSearch"
Placeholder ="{i18n:Translate App_Search}"
HorizontalOptions="FillAndExpand"
VerticalOptions ="FillAndExpand"
HeightRequest ="40"
BackgroundColor ="Transparent"
FontSize ="14"
TextColor ="Black"
FontAttributes ="None">
</rendered:BaseEntry>
</StackLayout>
<StackLayout
Orientation ="Vertical"
Spacing ="0"
Padding ="0,0,0,0"
VerticalOptions ="Fill"
HorizontalOptions="End"
x:Name ="slSearch"
WidthRequest ="40">
<Image
Source ="ic_search_blue"
Aspect ="AspectFit"
WidthRequest ="15"
HeightRequest ="15"
VerticalOptions ="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</StackLayout>
</RelativeLayout>
<ListView
x:Name ="listView"
SeparatorVisibility ="None"
ItemsSource ="{Binding PartyList}"
BackgroundColor ="{StaticResource GrayLightBackground}"
HasUnevenRows ="false"
RowHeight ="74"
VerticalOptions ="FillAndExpand"
RelativeLayout.XConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0, Constant=0}"
RelativeLayout.YConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=74}"
RelativeLayout.WidthConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=0}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-74}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout
Orientation ="Vertical" >
<StackLayout
Orientation ="Horizontal"
HorizontalOptions="FillAndExpand"
VerticalOptions ="CenterAndExpand"
HeightRequest ="52"
Padding ="10"
BackgroundColor ="White">
<StackLayout
Orientation ="Vertical"
HorizontalOptions="StartAndExpand"
BackgroundColor ="White">
<rendered:BaseLabel
Text ="{Binding PartyName}"
HorizontalOptions="StartAndExpand"
VerticalOptions ="Fill"
Style ="{StaticResource RowStyle}" />
<StackLayout
Padding ="0,5"
Orientation ="Horizontal">
<rendered:BaseLabel
Text ="{i18n:Translate PartyList_PartyType}"
HorizontalOptions="Start"
VerticalOptions ="Fill"
Style ="{StaticResource RowStyle}" />
<rendered:BaseLabel
Text ="{Binding PartyType}"
HorizontalOptions="Center"
VerticalOptions ="Fill"
Style ="{StaticResource RowStyle}" />
</StackLayout>
</StackLayout>
<rendered:BaseLabel
Text ="{Binding LocationDescription}"
HorizontalOptions="End"
VerticalOptions ="CenterAndExpand"
Style ="{StaticResource RowStyle}" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RelativeLayout>
</ContentPage.Content>
</basepage:BasePage>
我还想补充一点,这个问题只在iOS for android中完美运行。请检查并告诉我我错过了什么,因为我是xamarin的新手。