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.

[Bug] UriValidationBehavior didn't change style of Border

See original GitHub issue

Description

I try using this behaviour to update the style of a Border based on the validation result of an Entry. The validation result is updated correctly as the user types but the Border’s style is not updated

Stack Trace

No Stack Trace

Link to Reproduction Sample

Check out this branch: https://github.com/KafkaWannaFly/WibuTube/tree/UriValidationBehavior-Bug-Reproduction at MainPage.xaml

Example code

<Border x:Name="urlEntryBorder"
                            Padding="0"
                            Margin="0">
	<Entry x:Name="urlEntry"
                             ClearButtonVisibility="WhileEditing"
                             IsSpellCheckEnabled="false"
                             Keyboard="Url"
                             Grid.Column="0"
                             Placeholder="YouTube url..."
                             ReturnCommand="{Binding SearchVideoCommand}"
                             ReturnType="Search"
                             Text="{Binding Url, Mode=TwoWay}"
                             VerticalTextAlignment="Center"></Entry>
	<Border.Behaviors>
		<toolkit:UriValidationBehavior x:Name="validator"
                                                         Value="{Binding Url}"
                                                         InvalidStyle="{StaticResource InvalidEntryStyle}"
                                                         ValidStyle="{StaticResource ValidEntryStyle}"
                                                         Flags="ValidateOnValueChanged"
                                                         UriKind="Absolute" />
	</Border.Behaviors>
</Border>
<Button Grid.Column="1"
                          IsEnabled="True"
                          Padding="12"
                          FontFamily="Segoe MDL2 Assets"
                          FontSize="20"
                          BindingContext="{x:Reference validator}"
                          x:DataType="toolkit:UriValidationBehavior"
                          Text="{Binding Path=IsValid}" />

Steps to Reproduce

  1. Run the code, targeting the Window machine. You will see 1 text input and 1 button
  2. Input random characters on the text input. Button text change to False
  3. Input a valid URL (eg. https://github.com/). Button text change to True

Expected Behavior

The border colour of the text input should be red when False and green when True

Actual Behavior

The border colour of the text input doesn’t change

Basic Information

  • Version with issue: 1.0.0
  • Last known good version: 1.0.0
  • IDE: Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.3.0 Preview 1.1
  • Platform Target Frameworks: net6.0-windows10.0.19041.0

Workaround

No workaround

Reproduction imagery

image

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
KafkaWannaFlycommented, Jun 16, 2022

Hi @bijington

I think I found the solution. The root cause may come from default Border style in Style.xaml and I copied it. Which is:

    <Style TargetType="Border">
        <Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
        <Setter Property="StrokeShape" Value="Rectangle"/>
        <Setter Property="StrokeThickness" Value="1"/>
    </Style>

There might be something wrong with the StrokeShape property. Sadly, the IDE didn’t prompt any error. I change from:

<Style x:Key="InvalidEntryStyle"
               TargetType="Border">
            <Setter Property="Stroke"
                    Value="Red" />
            <Setter Property="StrokeShape"
                    Value="Rectangle" />
            <Setter Property="StrokeThickness"
                    Value="1" />
        </Style>

To:

<Style x:Key="InvalidEntryStyle"
               TargetType="Border">
            <Setter Property="Stroke"
                    Value="Red" />
            <Setter Property="StrokeThickness"
                    Value="1" />
            <Setter Property="StrokeShape">
                <Setter.Value>
                    <RoundRectangle CornerRadius="8" />
                </Setter.Value>
            </Setter>
        </Style>

So, I conclude that there is nothing wrong with the UriValidationBehavior and we can close this issue.

0reactions
bijingtoncommented, Jun 17, 2022

@KafkaWannaFly thank you for the update and investigating the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing label color on JS validation doesn't work and ...
If validation fails on firstName, everything works fine; label turns red and input border too. But wwhen failing validation on any other input, ......
Read more >
Skin rule option "Error Border" and "Error Background ...
on PE 7.1.9, it seems "Error Border" and "Error Background" option does not have any effect on a text control which contains validation...
Read more >
CSS Container Border
I am trying to create a white border container around all my content. The container DIV is in the xhtml fine and will...
Read more >
Form Validation UX in HTML and CSS
:valid , in this case, is ensuring the required condition is met, but that selector is also useful for validating the type of...
Read more >
CSS Examples
Below are some commonly requested styling changes that aren't currently included in the visual form styler settings or in the field options.
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