2016-09-13 9 views
0

こんにちは私は、メインメニューを持つxamrainフォームアプリケーションに取り組んでいます。数学ボタンをクリックするとMathHomeページに移動しますが、ホームページのボタンをクリックするとクラッシュします。私のxamarinフォームアプリケーション内のサブフォルダにxmlns:localを宣言する方法は?

heres

<?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:SchoolTools.Math.ViewModels;assembly=SchoolTools" 
      x:Class="SchoolTools.MathPage"> 
    <ContentPage.Resources> 
    <ResourceDictionary> 
     <Style x:Key="NumberStyle" TargetType="Button"> 
     <Setter Property="BackgroundColor" Value="White"/> 
     <Setter Property="TextColor" Value="Black"/> 
     <Setter Property="BorderRadius" Value="0"/> 
     <Setter Property="Font" Value="36"/> 
     </Style> 
     <Style x:Key="OperationsStyle" TargetType="Button"> 
     <Setter Property="BackgroundColor" Value="#FFA500"/> 
     <Setter Property="TextColor" Value="White"/> 
     <Setter Property="BorderRadius" Value="0"/> 
     <Setter Property="Font" Value="36"/> 
     </Style> 
     <Style x:Key="BackSpaceButtonStyle" TargetType="Button"> 
     <Setter Property="BackgroundColor" Value="Black"/> 
     <Setter Property="TextColor" Value="White"/> 
     <Setter Property="BorderRadius" Value="0"/> 
     <Setter Property="Font" Value="Bold,40"/> 
     <Setter Property="VerticalOptions" Value="CenterAndExpand"/> 
     <Setter Property="HorizontalOptions" Value="CenterAndExpand"/> 
     </Style> 
     <Style x:Key="CleanButtonStyle" TargetType="Button"> 
     <Setter Property="BackgroundColor" Value="Teal"/> 
     <Setter Property="TextColor" Value="Black"/> 
     <Setter Property="BorderRadius" Value="0"/> 
     <Setter Property="Font" Value="36"/> 
     </Style> 
     <Style x:Key="MainLabelStyle" TargetType="Label"> 
     <Setter Property="BackgroundColor" Value="Black"/> 
     <Setter Property="TextColor" Value="White"/> 
     <Setter Property="Font" Value="35"/> 
     <Setter Property="YAlign" Value="Center"/> 
     <Setter Property="XAlign" Value="Center"/> 
     </Style> 
    </ResourceDictionary> 
    </ContentPage.Resources> 

    <Grid Padding="5,0" RowSpacing="1" BackgroundColor="Black" ColumnSpacing="1"> 
    <Grid.BindingContext> 
     <local:MainViewModel /> 
    </Grid.BindingContext> 

    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="*"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="*" /> 
    </Grid.ColumnDefinitions> 

    <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" 
     Text="{Binding DisplayValue}" Style="{DynamicResource MainLabelStyle}" /> 
    <Button Text="←" Grid.Row="1" Grid.Column="3" Command="{Binding BackspaceCommand}" 
     Style="{DynamicResource BackSpaceButtonStyle}" /> 

    <Button Text="7" Grid.Row="3" Grid.Column="0" Command="{Binding NumberComamnd}" 
     CommandParameter="7" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="8" Grid.Row="3" Grid.Column="1" Command="{Binding NumberComamnd}" 
    CommandParameter="8" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="9" Grid.Row="3" Grid.Column="2" Command="{Binding NumberComamnd}" 
    CommandParameter="9" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="4" Grid.Row="4" Grid.Column="0" Command="{Binding NumberComamnd}" 
    CommandParameter="4" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="5" Grid.Row="4" Grid.Column="1" Command="{Binding NumberComamnd}" 
    CommandParameter="5" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="6" Grid.Row="4" Grid.Column="2" Command="{Binding NumberComamnd}" 
    CommandParameter="6" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="1" Grid.Row="5" Grid.Column="0" Command="{Binding NumberComamnd}" 
    CommandParameter="1" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="2" Grid.Row="5" Grid.Column="1" Command="{Binding NumberComamnd}" 
    CommandParameter="2" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="3" Grid.Row="5" Grid.Column="2" Command="{Binding NumberComamnd}" 
    CommandParameter="3" Style="{DynamicResource NumberStyle}"/> 
    <Button Text="0" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="3" 
    CommandParameter="0" Style="{DynamicResource NumberStyle}" Command="{Binding NumberComamnd}" /> 

    <Button Text="." Grid.Row="6" Grid.Column="3" Command="{Binding AddPointCommand}" 
    Style="{DynamicResource OperationsStyle}"/> 

    <Button Text="/" Grid.Row="2" Grid.Column="2" Command="{Binding OperatorCommand}" 
    CommandParameter="/" Style="{DynamicResource OperationsStyle}"/> 
    <Button Text="x" Grid.Row="2" Grid.Column="3" Command="{Binding OperatorCommand}" 
    CommandParameter="x" Style="{DynamicResource OperationsStyle}" Font="25"/> 
    <Button Text="-" Grid.Row="3" Grid.Column="3" Command="{Binding OperatorCommand}" 
    CommandParameter="-" Style="{DynamicResource OperationsStyle}"/> 
    <Button Text="+" Grid.Row="4" Grid.Column="3" Command="{Binding OperatorCommand}" 
    CommandParameter="+" Style="{DynamicResource OperationsStyle}"/> 

    <Button Text="√" Grid.Row="2" Grid.Column="1" Command="{Binding OperatorCommand}" 
    CommandParameter="√" Style="{DynamicResource OperationsStyle}"/> 

    <Button Text="=" Grid.Row="5" Grid.Column="3" Command="{Binding CalculationCommand}" 
      Style="{DynamicResource OperationsStyle}"/> 
    <Button Text="C" Grid.Row="2" Grid.Column="0" Command="{Binding CleanCommand}" 
      Style="{DynamicResource CleanButtonStyle}"/> 
    </Grid> 
</ContentPage> 

私は私のxmlnsを考える:mathpageのための私のコードのローカルは、クラスにXAMLの参照を台無しにされたMainViewModelの魔女のviewmodels

と呼ばれる数学内のサブフォルダその後、数学と呼ばれるプロジェクトでフォルダ内にあるとされます

この問題を解決する方法に関するご意見はありますか?

+0

これはフォルダに関するものではなく、 'MainViewModel 'の名前空間は何ですか? –

+0

名前空間は次のとおりです。SchoolTools.Math.ViewModelsありがとうございました。返信は – Phoneswapshop

+0

となりました。出力ウィンドウに表示されるエラーメッセージは何ですか? –

答えて

0

この問題は、local名前空間宣言には含まれていないようですが、廃止とマークされたプロパティを使用しているようです。

エラーメッセージが参照するこのXAMLの部分を見てください。

<Style x:Key="MainLabelStyle" TargetType="Label"> 
    <Setter Property="BackgroundColor" Value="Black"/> 
    <Setter Property="TextColor" Value="White"/> 
    <Setter Property="Font" Value="35"/> 
    <Setter Property="YAlign" Value="Center"/> 
    <Setter Property="XAlign" Value="Center"/> 
</Style> 

我々はXamarinフォームドキュメントのYAlignXAlignを検索する場合は、それらは古いものとしてマークされて表示されます。今度はVerticalTextAlignmentHorizontalTextAlignmentをそれぞれ使用してください。

関連する問題