本記事の概要
この記事では Editorを読み取り専用にする方法について説明をします。
公式サイト情報はコチラを参照してください。
テキスト入力欄を読み取り専用にする
Editor のテキスト入力欄は、IsReadOnly プロパティに True を設定することで読み取り専用にすることができます。
XAML の例
XAML で Editor を読み取り専用にする例を以下に示します。
XAML の例
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MauiAppSample.MainPage"> <ScrollView> <VerticalStackLayout Spacing="25" Padding="30,0" VerticalOptions="Center"> <Label Text="読み取り専用 Editor" /> <Editor Text="Hello .NET MAUI" IsReadOnly="True" /> </VerticalStackLayout> </ScrollView> </ContentPage>
C# の例
以下は 先ほどのXAML の例を コードビハインドで行う例です。
C# の例
public MainPage() { InitializeComponent(); myEditor1.IsReadOnly = true; }
XAML の例
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MauiAppSample.MainPage"> <ScrollView> <VerticalStackLayout Spacing="25" Padding="30,0" VerticalOptions="Center"> <Label Text="読み取り専用 Editor" /> <Editor x:Name="myEditor" Text="Hello .NET MAUI" /> </VerticalStackLayout> </ScrollView> </ContentPage>
.NET MAUI Tips
本サイトでまとめている .NET MAUI Tips の一覧はこちらから確認できます。
Please follow and like us:
コメント