A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hi AlexJohanson-0792,
Welcome to our Microsoft Q&A platform!
By default, the label text in the frame will wrap automatically.
So you just need to define xaml as follows.
<ContentPage.BindingContext>
<local:MainPageViewModel/>
</ContentPage.BindingContext>
<StackLayout>
<Entry Text="{Binding EntryText}"/>
<Frame CornerRadius="25" BackgroundColor="Azure">
<StackLayout>
<Label Text="here is the title" FontSize="Small"/>
<Label Text="{Binding LabelText}" FontSize="Medium"/>
</StackLayout>
</Frame>
<Button Text="Entry to Label" Command="{Binding SaveCommand}"/>
</StackLayout>
Then define the corresponding properties "EntryText" and "LabelText" in the ViewModel, implement interface INotifyPropertyChanged and define the command "SaveCommand" which will pass entry's text to label.
class MainPageViewModel : INotifyPropertyChanged
{
string entryText;
public string EntryText
{
get => entryText;
set
{
entryText = value;
OnPropertyChanged("EntryText");
}
}
string labelText;
public string LabelText
{
get => labelText;
set
{
labelText = value;
OnPropertyChanged("LabelText");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
public ICommand SaveCommand { get; set; }
public MainPageViewModel()
{
SaveCommand = new Command(Save);
}
void Save()
{
LabelText = entryText;
}
}
Regards,
Kyle
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.