MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.14k stars 3.43k forks source link

How disable CharacterCounter on TextBox #2247

Closed Ares-87 closed 3 years ago

Ares-87 commented 3 years ago

Hi, after latest update, my textboxes show by default the character counter under the box.

To remove it, I tried to add a default style inside my xaml, like this: Style="{DynamicResource MaterialDesignTextBoxBase}"

Unfortunately this not solve the problem. How I can disable min/max lenght counte? Thank you.

Cattura

Keboo commented 3 years ago

Looks like you are wanting something similar to what was requested here. Simply setting an empty style to the TextFieldAssist.CharacterCounterStyle property.

<TextBox>
    <materialDesign:TextFieldAssist.CharacterCounterStyle>
        <Style TargetType="TextBlock" />
    </materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>
Ares-87 commented 3 years ago

Looks like you are wanting something similar to what was requested here. Simply setting an empty style to the TextFieldAssist.CharacterCounterStyle property.

<TextBox>
    <materialDesign:TextFieldAssist.CharacterCounterStyle>
        <Style TargetType="TextBlock" />
    </materialDesign:TextFieldAssist.CharacterCounterStyle>
</TextBox>

Thank you, but there is a way to disable to all Textboxes by xaml Style?

Keboo commented 3 years ago

Yes, you can create an implicit style targeting TextBoxes. You can put something like this in your App.xaml.

<Style TargetType="TextBox" BasedOn="{StaticResource MaterialDesignTextBox}">
    <Setter Property="materialDesign:TextFieldAssist.CharacterCounterStyle">
        <Setter.Value>
            <Style TargetType="TextBlock" />
        </Setter.Value>
    </Setter>
</Style>
Keboo commented 3 years ago

In the next release there will be a new attached property you can use to hide the character counter.

<TextBox
    MaxLength=""10""
    materialDesign:TextFieldAssist.CharacterCounterVisibility=""Collapsed""
/>
Ares-87 commented 3 years ago

Thank you so much!

Yes, you can create an implicit style targeting TextBoxes. You can put something like this in your App.xaml.

<Style TargetType="TextBox" BasedOn="{StaticResource MaterialDesignTextBox}">
    <Setter Property="materialDesign:TextFieldAssist.CharacterCounterStyle">
        <Setter.Value>
            <Style TargetType="TextBlock" />
        </Setter.Value>
    </Setter>
</Style>
marcosgerene commented 3 years ago

Hi everyone,

I had the same trouble and I did:

<Setter Property="materialDesign:TextFieldAssist.CharacterCounterStyle" Value="{x:Null}" />

Thank you all.

9helix commented 9 months ago

can materialDesign:TextFieldAssist.CharacterCounterVisibility be set from code-behind?

Keboo commented 9 months ago

@9helix yes, this is just an attached property, you can see how to set these in code here