2017-09-26 3 views
0

Ich bin derzeit nicht in der Lage, die untergeordneten Ansichten in meinem Layout für UWP zu erhöhen, aber es funktioniert für Android. (Derselbe Code ändert nur die Bildquelle) Irgendeine gute Seele kann mir dabei helfen?Ansichten auf UWP-Xamarin-Formularen können nicht erhöht werden

Der folgende Code sollte 2 Bilder und 2 Tasten anzeigen. Die Bilder überschneiden sich, während ich teste, ob das Bild erfolgreich angehoben wird. Auf Android funktioniert es einwandfrei, aber auf UWP tut es nicht und ich bin mir nicht sicher, was ich verpasst haben könnte, da PCL allgemein üblich ist, also sollte der Code auf beiden Plattformen funktionieren.

Unten ist mein Code:

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:local="clr-namespace:UWPRaiseTest" 
      x:Class="UWPRaiseTest.MainPage"> 

    <ContentView> 
    <StackLayout Orientation="Vertical" BackgroundColor="Violet" x:Name="EntireLayout" IsEnabled="True"> 
     <RelativeLayout x:Name="ImageHolder" IsEnabled="True"> 
       <Image x:Name="Img1" Source="Assets/StoreLogo.png" BackgroundColor="AliceBlue" IsEnabled="True" 
         RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0,Constant=100}" 
         RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0, Constant=0}" /> 
       <Image x:Name="Img2" Source="Assets/StoreLogo.png" BackgroundColor="Red" IsEnabled="True" 
         RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0,Constant=120}" 
         RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0, Constant=0}" /> 
      </RelativeLayout> 
      <Button x:Name="RaiseObj1" BackgroundColor="Aquamarine" Text="Raise image 1 " Clicked="RaiseObj1_OnClicked" /> 

      <Button x:Name="RaiseObj2" BackgroundColor="Aquamarine" Text="Raise image 2" Clicked="RaiseObj2_OnClicked"/> 

     </StackLayout> 
</ContentView> 

</ContentPage> 

MainPage.xaml.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using Xamarin.Forms; 

namespace UWPRaiseTest 
{ 
    public partial class MainPage : ContentPage 
    { 
     public MainPage() 
     { 
      InitializeComponent(); 

     } 

     private void RaiseObj1_OnClicked(object sender, EventArgs e) 
     { 
      ImageHolder.RaiseChild(Img1); 
      ImageHolder.LowerChild(Img2); 

      EntireLayout.RaiseChild(Img1); 
     } 

     private void RaiseObj2_OnClicked(object sender, EventArgs e) 
     { 
      ImageHolder.RaiseChild(Img2); 
      EntireLayout.RaiseChild(Img2); 
      ImageHolder.LowerChild(Img1); 


     } 
    } 
} 

Antwort

0

Dies ist in der 2.4.0 Prerelease fixiert baut. Sie können sich auf den ursprünglich eingereichten Fehler here beziehen.

Verwandte Themen