「Xamarinエキスパート養成読本」を読みながら、例題を試しています。
ある例題で画面が全く表示されません
画面を定義している Xaml にエラーは見当たりません。
Xaml に問題がありそうな場合、どの様にデバッグすれば良いのでしょうか?
単純に下記のxamlを表示するだけのプログラムを作成し、実行してみましたが
画面に何も表示されません。
このxamlを単純にすると表示されるので、このxamlが問題だと思うのですが、
xaml初心者のためデバッグ方法が知りたいです。
エラーメッセージ
AddressSearch.Xalm
<?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:AddressSearchApp" x:Class="AddressSearchApp.AddressSearchPage">
</ContentPage> 問題のxamlを <Label Text="Hello World" /><ContentPage.Resources> <ResourceDictionary> <style x:Key="labelStyle" TargetType="Label"> <Setter Property="TextColor" Value="#a8a8a8"/> <Setter Property="FontSize" Value="Small"/> </style> <style x:Key="fieldStyle" TargetType="Label"> <Setter Property="TextColor"> <OnPlatform x:TypeArguments="Color" Android="white" iOS="Black" /> </Setter> <Setter Property="Fontsize" Value="Medium"/> </style> <Style x:Key="fieldView" TargetType="ContentView"> <Setter Property="Padding" Value="10,0,0,0"/> </Style> </ResourceDictionary> </ContentPage.Resources> <ContentPage.Content> <ScrollView> <StackLayout> <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" BackgroundColor="#545454"> <StackLayout Padding="10,10,10,10" HorizontalOptions="Start"> <Label Text="住所検索" TextColor="White" FontAttributes="Bold" FontSize="Medium" /> <Label x:Name="AddressLabel" Text="郵便番号" Style="{StaticResource lableStyle}" /> <Entry x:Name="AddressEntry" WidthRequest="100" /> </StackLayout> <StackLayout Padding="0,0,0,10" VerticalOptions="End"> <Button x:Name="GetAddressSearchBtn" Text="検索" WidthRequest="60" BorderWidth="1"> <Button.TextColor> <OnPlatform x:TypeArguments="Color" iOS="White"/> </Button.TextColor> <Button.BorderColor> <OnPlatform x:TypeArguments="Color" iOS="White"/> </Button.BorderColor> </Button> </StackLayout> </StackLayout> <StackLayout Padding="10,10,10,10" HorizontalOptions="Start"> <Label Text="都道府県名" Style="{StaticResource lableStyle}"/> <ContentView Style="{StaticResource fieldView}"> <Label x:Name="stateNameLabel" Text="{Binding stateName}" Style="{StaticResource fieldStyle}"> <Label.TextColor> <OnPlatform x:TypeArguments="Color" iOS="Black"/> </Label.TextColor> </Label> </ContentView> <Label Text="市・区・群名" Style="{StaticResource labelStyle}"/> <ContentView Style="{StaticResource fieldView}"> <Label x:Name="cityLabel" Text="{Binding city}" Style="{StaticResource fieldStyle}"> <Label.TextColor> <OnPlatform x:TypeAruguments="Color" iOS="Black"/> </Label.TextColor> </Label> </ContentView> <Label Text="町・村名" Style="{StaticResource labelStyle}"/> <ContentView Style="{StaticResource fieldView}"> <Label x:Name="streetLabel" Text="{Binding street}" Style="{StaticResource fieldStyle}"> <Label.TextColor> <OnPlatform x:TypeAruguments="Color" iOS="Black"/> </Label.TextColor> </Label> </ContentView> </StackLayout> </StackLayout> </ScrollView> </ContentPage.Content>
とすれば、表示される。
また、ContentPage.Resources を定義しないと表示されます。
windows10 Pro
xamarin for visual studio 2017
エミュレータは
Visualstudio_androi-23x86 phone(Android6.0 API23)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/08 05:26