Hello community,
I am a beginner in c# and wpf. I used to program Python, so I am not totally new in programming. I currently try to program a License generator for my company. Since I really want to learn wpf with generating my own GUI, I spend a lot of time with the resource dictionary.
Right now, I stuck with the Text Box.
I created a Text Box dictionary, and everything locks fine. I can type on it, but if I try to read the written text it is always empty.
Now I hope someone of you guys can help me to understand what my fault is. Thanks!
Best,
Mathias
Text Box dictionary:
Text Box Call:
void SubmitButton_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine(mac_textbox.Text);
}
Mathias Stritzke26 reputationPosted Jun 13, 2021, 7:34 AM EDT
Hello all,
thanks for your help, but I found a better solution. This solution is maybe not nice but free of C# code.
After a couple days of 12h self-training I slowly understand most of it. Ok it is difference of active using and understanding like a language.
But anyway, it is seeming that cannot get the text out of a Textbox with is set inside the Resource Dictionary at all.
My way is now to have a Textbox above the Style, with transparent background and border. The Textbox below will be disabled. To get the still the watermark from the other Textbox inside the Resource Dictionary I use the binding command.
This code can be used for all textboxes and the only thing what need be changed is ElementName and Uid which is used to copy the watermark text inside the Resource Dictionary TextboxTheme.xaml
Best,
Mathias
IsEnabled="False"
Style="{StaticResource ModernTextBox}"/>
Background="Transparent"
BorderThickness="0"
Foreground="White"
CaretBrush="White"
MaxLength="4"/>
Anant VernekarRank #1,055 · 1.8K reputationPosted Jun 11, 2021, 2:06 AM EDT
Can you please share the main form complete XAML content?
Mathias Stritzke26 reputationPosted Jun 12, 2021, 3:15 AM EDT
Anant VernekarRank #1,055 · 1.8K reputationPosted Jun 12, 2021, 7:47 AM EDT