question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with Material Design Textbox

See original GitHub issue

I’m new to programming and started to make an application for school. For that I use C# WPF and for a good-looking Application I installed Material Design.

First I started the Demo of Material Design and after a quick view I found a nice TextBox with a border and a Checkbox on top of it. The code to copy was this (It’s the example from Fields -> Outlined Text field in the Demo)

<StackPanel> <CheckBox x:Name="MaterialDesignOutlinedTextFieldTextBoxEnabledComboBox" IsChecked="True" Margin="32,0,0,8"> Enabled </CheckBox> <TextBox Style="{StaticResource MaterialDesignOutlinedTextFieldTextBox}" Margin="32,0,0,0" VerticalAlignment="Top" Height="100" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" materialDesign:HintAssist.Hint="This is a text area" IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignOutlinedTextFieldTextBoxEnabledComboBox}" /> </StackPanel>

Because I just needed the Textbox, I deleted the Code of the CheckBox and implemented the rest inside my application. So the code now is like this:

<TextBox Style="{StaticResource MaterialDesignOutlinedTextFieldTextBox}" Margin="32,0,0,0" VerticalAlignment="Top" Height="100" AcceptsReturn="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" materialDesign:HintAssist.Hint="This is a text area" />

The problem now is, that I can’t edit the textbox.

example

As you can see in the picture above, the TextBox on the top is a normal TextBox (which I can edit) and the TextBox below is with Style="{StaticResource MaterialDesignOutlinedTextFieldTextBox}" (which I cant edit/type in).

I guess the TextBox is still linked to the CheckBox and because I deleted it, somehow i can’t write in it anymore. It all works fine with a standard textbox, but with the copied code i cant do anything, just see the TextBox with its rounded border.

How can I fix the problem, so I have the TextBox with the rounded border while I can edit it? I would appreciate it, if somebody could help me.

Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jespershcommented, Nov 29, 2018

There’s nothing I can recommend you to do, except not to try to use the MaterialDesignOutlinedTextFieldTextBox in the height restricted way you’re attempting. As I see it, then you would end up with triple borders, reimplementing the entire style or breaking the validation or other effects.

If you want to ignore that, then copy paste https://raw.githubusercontent.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/master/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml into a new file in your project, modify and rename the styles and add the style file in your app.xaml

1reaction
jespershcommented, Nov 26, 2018

You can edit in it, it is just that the text is somewhere… else Try entering into the box “1234”, ctrl-a to select all and copy it. Paste it in somewhere else. Simply remove the Height <TextBox Width="85" Style="{StaticResource MaterialDesignOutlinedTextFieldTextBox}" />

I suspect that you’re trying to achieve something with MaterialDesignOutlinedTextFieldTextBox that it wasn’t intended to do. The Outlined trigger is setting some values that are hardcoded: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/e1d240de3155654cfae52c31799bc9341f767582/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.TextBox.xaml#L163-L176

My recommendation would be to create your own textbox style to suit your specific needs (it is the margin and padding values that were screwing you over)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Material Design Text Fields Are Badly Designed
Conventional text fields don't have the above problems because it's clear where the answer goes and they have a legible, readily available label...
Read more >
C# WPF - Problem with Material Design Textbox
I'm new to programming and started to make an application for school. For that I use C# WPF and for a good-looking Application...
Read more >
Form inputs redesigned. The usability issues with Material…
With our Material Design form inputs, the minimalist affordances ... A comparison of three text field designs within a small address form.
Read more >
Text fields
This demo lets you preview the text field component, its variations, and configuration options. Each tab displays a different type of text field....
Read more >
Text fields – Material Design 3
Make sure text fields look interactive; Two types: filled and outlined; The text field's state (blank, with input, error, etc) should be visible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found