I’m beginner in WPF coming from WinForms.
I have searched long no success on the internet to get a working example of how to create a hidden text box.
I tried many sample codes but can’t piece together one that is complete enough to help me do this. So be patient with me as I’m floundering.
In summary I would like to get help in building a complete working sample using MVVM, Net Core 8 if it makes a difference. Of a project where the TextBox is hidden and is controlled via the MainWindowViewModel.cs. Why you’re asking, right now I just want to succeed in making the TexBox invisible as I can’t find a way to do this.
<Window x:Class="WPFTextboxvisibility.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFTextboxvisibility"
mc:Ignorable="d"
Title="MainWindow" Height="100" Width="200">
<Grid>
<TextBox x:Name="txtBox" Text="I want to be invisible." HorizontalAlignment="Center" Height="28"
Visibility="{Binding ????????}"/>
The question marks are because I believe this is the trigger in the xaml.
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace WPFTextboxvisibility
{
public partial class MainWindowViewModel : ObservableRecipient
{
public MainWindowViewModel()
{
}
}
}
Why is my MainWindowViewModel empty, because I need help.