を使用して.cs)。私のxamlファイルの作成まで、すべてのことが順調に進みました。 xaml.cs(ログインページに入っていると仮定します)では、ログインボタンをクリックするとサインアップページに移動します。ユニバーサルのWindows 10アプリケーションは、Visual Studio 2015
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
namespace LoginApp.Model
{
class LoginPage
{
public void Login_Click(object sender, RoutedEventArgs e) {
}
public void SiguUp_Click(object sender, RoutedEventArgs e) {
NavigationService.Navigate(new Uri("/Views/SignUpPage.xaml", UriKind.Relative));
}
}
}
NavigationServiceに問題があります(「NavigationServiceという名前は現在のコンテキストに存在しません」ということです)。
私が立ち往生している2番目のポイントは、サインアップのPage.xaml.cs.にあります。私は名前がtxtusername
のテキストボックスを持っています。赤い線は「名前は現在のコンテキスト内に存在しない」と言っTxtUserNameとメッセージボックスを指し、このコードで
using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Windows.UI.Xaml;
namespace LoginApp.Model
{
class SignUpPage
{
IsolatedStorageFile ISOFile = IsolatedStorageFile.GetUserStoreForApplication();
public void Submit_Click(object sender, RoutedEventArgs e) {
if (!Regex.IsMatch(TxtUserName.Text.Trim(), @"^[A-Za-z_][a-zA-Z0-9_\s]*$")) {
MessageBox.Show("Invalid UserName");
}
}
}
}
<Page
x:Class="LoginApp.SignUpPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LoginApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White">
<Grid Margin="10,10,-5,-10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="User Registration :" Grid.Row="0" FontSize="40" Foreground="Black"/>
<TextBlock Text="UserName" Grid.Row="1" Foreground="Black" Margin="0,25,0,0"/>
<TextBox Name="TxtUserName" BorderBrush="LightGray" Grid.Row="1" Margin="100,0,0,0" GotFocus="Txt_GotFocus"/>
<TextBlock Text="Password:" Grid.Row="2" Margin="0,25,0,0" Foreground="Black"/>
<PasswordBox Name="TxtPwd" BorderBrush="LightGray" Grid.Row="2" Margin="100,0,0,0" GotFocus="pwd_GotFocus"/>
<TextBlock Text="Address:" Grid.Row="3" Margin="0,25,0,0" Foreground="Black"/>
<TextBox Name="TxtAddr" BorderBrush="LightGray" Margin="100,0,0,0" GotFocus="Txt_GotFocus"/>
<TextBlock Text="Gender:" Grid.Row="4" Margin="0,25,0,0" Foreground="Black"/>
<RadioButton Name="GenMale" Background="LightGray" Grid.Row="4" Margin="100,0,0,0" Content="Male" Foreground="Black"/>
<RadioButton Name="GenFemale" Background="LightGray" Grid.Row="4" Margin="200,0,0,0" Content="Female" Foreground="Black"/>
<TextBlock Text="Phone No:" Grid.Row="5" Margin="0,25,0,0" Foreground="Black"/>
<TextBox Name="TxtPhNo" Grid.Row="5" Margin="100,0,0,0" Foreground="LightGray" MaxLength="10" InputScope="Digits" GotFocus="Txt_GotFocus"/>
<TextBlock Text="EmailID:" Grid.Row="6" Margin="0,25,0,0" Foreground="Black"/>
<TextBox Name="TxtEmail" Grid.Row="6" Margin="100,0,0,0" GotFocus="TxtGotFocus"/>
<Button BorderBrush="Transparent" Background="#FF30DABB" Content="Submit" Name="BtnSubmit" Click="Submit_Click" Grid.Row="7" Margin="0,25.667,0,-41.667" Width="345"/>
</Grid>
</Grid>
</Page>
:私は、テキストボックスにテキストを追加して、メッセージボックスを使用しようとしています。
「正しい参照を使用してPresentationFramework.dllへの参照を追加する」という記事が見つかりました。リファレンスを追加し、Select Assemblies> Framework> PresentationFrameworkコンポーネントのチェックボックスをクリックし、okをクリックしました。
この時点では、「マシンにフレームワークアセンブリが見つかりませんでした」と表示されています。
私のコンピュータに.NET Framework 4.5がインストールされています。
あなたのチュートリアルは、UWPアプリケーション用ではありませんが、Windows Phone 7.x/8.x用のチュートリアルは、これと似ています。 –
他の例を試してみることはできますか? – Rakesh