Hi, @hossein tavakoli . Welcome Microsoft Q&A.
I am testing with the code below and it works. Could the error be caused by something else?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>True</UseWPF>
<UseWindowsForms>True</UseWindowsForms>
<PlatformTarget>x86</PlatformTarget>
<PackageIcon></PackageIcon>
<RunAnalyzersDuringBuild>True</RunAnalyzersDuringBuild>
<Platforms>AnyCPU;ARM32</Platforms>
</PropertyGroup>
</Project>
<Grid>
<WindowsFormsHost x:Name="host" Width="300" Height="300">
</WindowsFormsHost>
</Grid>
public partial class MainWindow : Window
{
MaskedTextBox mtb = new MaskedTextBox("00/00/0000");
ToolTip tt=new System.Windows.Forms.ToolTip();
public MainWindow()
{
InitializeComponent();
mtb.Width = 200;
mtb.Height= 100;
mtb.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox1_MaskInputRejected);
mtb.KeyDown += new KeyEventHandler(maskedTextBox1_KeyDown);
host.Child = mtb;
}
void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) { ... }
void maskedTextBox1_KeyDown(object sender, KeyEventArgs e) { tt.Hide(mtb); }
}