私はXamarin.Formsのhello xamarinクイックスタートプロジェクトhttps://developer.xamarin.com/guides/xamarin-forms/getting-started/hello-xamarin-forms/quickstart/を以下だと私は生成されたコードで警告The private field Phoneword.MainPage.translateButon is assigned but its value is never used
を取得していますXamarin.Forms hello worldの例でビルド警告が表示されるのはなぜですか?その値は使用されません。
/Demo/Phoneword/obj/Debug/Phoneword.MainPage.xaml.g.cs(46,46): Warning CS0414: The private field `Phoneword.MainPage.translateButon' is assigned but its value is never used (CS0414) (Phoneword)
がここになぜ私が取得しています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" x:Class="XamDemo.MainPage">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness" iOS="20, 40, 20, 20" Android="20, 20, 20, 20" WinPhone="20, 20, 20, 20" />
</ContentPage.Padding>
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Orientation="Vertical" Spacing="15">
<Label Text="Enter a Phoneword:" />
<Entry x:Name="phoneNumberText" Text="1-855-XAMARIN" />
<Button x:Name="translateButon" Text="Translate" Clicked="OnTranslate" />
<Button x:Name="callButton" Text="Call" IsEnabled="false" Clicked="OnCall" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
のファイルその警告?プロジェクトは正常に動作しているように見え、翻訳ボタンはメソッドを呼び出して使用されています。同じように宣言されたようなcallButtonに対しても同じ警告は出ません。どうしたの?
これは意味があります。そのオブジェクトがコードの背後で参照されていたため、コールボタンと同じ警告が表示されていないことがわかりました。 – MonkeyBonkey