[xaml]でVIEWの定義したLabelなどを[xaml.cs]で取得し、操作をしたい。
以下のようなXML定義をしたうえで、xaml.csから
<Label Text="{Binding Title}"/>
にあたるLabel要素をContentPageから取得して変更するということはできないのでしょうか。
英語が読めないため、資料サイトをうまく探せず質問しました。
XML
1<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 2 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 3 xmlns:mvvm="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" 4 mvvm:ViewModelLocator.AutowireViewModel="true" 5 x:Class="PrismZXing.Views.MainPage" 6 Title="MainPage"> 7 <StackLayout HorizontalOptions="Center" VerticalOptions="Center"> 8 <Label Text="{Binding Title}"/> 9 <Button 10 Command="{Binding ScanTop}" 11 Text="{Binding TouchMe}" 12 > 13 </Button> 14 </StackLayout> 15</ContentPage>
C#
1 2namespace PrismZXing.Views 3{ 4 public partial class MainPage : ContentPage 5 { 6 public MainPage() 7 { 8 InitializeComponent(); 9 // コンポーネントの初期化後、ここで取得しLabelに対して操作をしたい 10 11 } 12 } 13}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/13 03:49