2017-11-11 157 views
2

使用xamarin表单开发跨平台应用程序,最初该应用程序是使用Xamarin.Forms.2.4.0.38779,目标框架为6.0以及Android支持库版本23.3.0构建的。 UI代码是:升级后的xamarin表单不能正确呈现按钮

// styles 
<Style x:Key="DefaultButtonStyle" TargetType="Button"> 
    <Setter Property="TextColor" Value="DodgerBlue"></Setter> 
    <Setter Property="BackgroundColor" Value="Transparent"></Setter> 
</Style> 
<Style x:Key="RoundBorderButtonStyle" TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}"> 
    <Setter Property="BorderWidth" Value="1"></Setter> 
    <Setter Property="BorderRadius" Value="30"></Setter> 
    <Setter Property="BorderColor" Value="DodgerBlue"></Setter> 
</Style> 

<StackLayout Margin="15,0" Spacing="20" Orientation="Horizontal"> 
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Copy"></Button> 
    <Button Style="{StaticResource RoundBorderButtonStyle}" HorizontalOptions="FillAndExpand" Text="Addresses"></Button> 
</StackLayout> 

然后vs2017得到了更新,所以没有xamarin形式,所以我还更新了项目中使用最新的库,与Xamarin.Forms.2.4.0.38779和android目标框架8.0版,支持库26.1.0.1。然后突然按钮不能正确渲染。 enter image description here

更新后:更新之前

enter image description here

还有什么我需要做更新xamarin形式?

更新

我创建了最低test case,借以说明问题,在VS创建一个跨平台的项目,唯一的文件更改为TestButton/TestButton/MainPage.xaml中。该应用程序截图:

enter image description here

+0

您能否发布'RoundBorderButtonStyle'的代码? –

+0

@ ElvisXia-MSFT它的帖子,上面的按钮xaml – fluter

+0

对不起,错过了,我会尝试在我身边。 –

回答

2

所以我还更新了项目中使用最新的库,与Xamarin.Forms.2.4.0.38779和android目标框架8.0版,支持库26.1.0.1。然后突然按钮不能正确呈现

我转载您的项目的问题,我发现它是由Xamarin.Forms库造成的。我注意到您的示例项目Xamarin.Forms的版本是最新版本(2.4.0.74863)。

解决方案:通过将Xamarin.Forms降级到2.4.280并执行干净的重建并重新安装该应用程序将解决该问题。

+0

我将Xamarin表格降级到2.4.0.280并再次尝试,但没有任何变化。一样的问题。 – fluter

+0

你有没有卸载你的手机/模拟器中的应用程序,并清理重建应用程序?此外,您还需要在PCL和Xamarin.Android项目中降级lib。 –

+0

是的,确实现在它卸载应用程序后现在工作。谢谢。 – fluter