I am new on this world and I have created this code in Xamarin forms, however I am not able to link the answer given in the visual Xamarin with the C# code. Any suggestion, please? Thanks
This is the code in C#
public MainPage()
{
InitializeComponent();
Button button = new Button
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
button.Clicked += async (sender, args) =>
{
await Navigation.PushAsync(new MainPage());
};
}
public void Button_Click(object sender, EventArgs e)
{
}
}
namespace animal
{
class animaltype
{
public static string Name(string a)
{
if (a == "Dog")
{
a = "oh that's cool";
return a;
}
else
a = " Pets are good company help to live longer";
return a;
}
}
}
This is the code in XAML
<StackLayout>
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Welcome to Namespaces!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<Label x:Name="dogbreed1" Text=" what type of dog breed do you have?" FontSize="Title" Padding="30,10,30,10"/>
<Entry x:Name="dogbreed" Placeholder="Enter text" />
<Button Text="Click here to see answer" Clicked="Button_Click"
Margin="5"
HorizontalOptions="Center"
VerticalOptions="Center"
FontSize="Large"
TextColor="Blue"/>
<Label x:Name="question"
Text="Answer" HorizontalTextAlignment="Center" TextColor="Blue" FontSize="36"/>
<Label Text="" FontSize="16" Padding="30,0,30,0"/>
<Label FontSize="16" Padding="30,24,30,0">
What I have tried:
I have changed the name of variable a by doing this way
if (Entry.dogbreed == "German Shepperd")
{
Label.question = "oh that's one of the smartest ones";
}
I have tried to substitute the variable a equal to Entry.dobreed, but it doesnt work, either. Thanks
but it hasnt work