dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

Binding Border.StrokeShape RoundRectangle CornerRadius not working #22637

Open AlleSchonWeg opened 4 months ago

AlleSchonWeg commented 4 months ago

Description

Hi, if you bind then CornerRadius to a ViewModel property the value is not recognized:

      <Border x:Name="myBorder"
              Margin="0,10,0,0"
              BackgroundColor="Blue"
              Padding="0"
              StrokeThickness="0">
        <Border.StrokeShape>
          <RoundRectangle CornerRadius="{Binding Corner}" />
        </Border.StrokeShape>
        <Label Text="Welcome to &#10;.NET Multi-platform App UI"
               Style="{StaticResource SubHeadline}"
               SemanticProperties.HeadingLevel="Level2"
               SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
      </Border>

Viewmodel:

        public TestViewModel()
        {
            Corner = new CornerRadius(4);
        }

The corner should be 4. But it's set to 0: image

Also if you click the button and set it to 12:

        private void OnCounterClicked(object sender, EventArgs e)
        {
            var model = (TestViewModel)BindingContext;
            model.Corner = new CornerRadius(12);
        }

Steps to Reproduce

Open Repro. Nightly Version: 8.0.60-ci.net8.24274.1 MauiApp8.zip

Link to public reproduction project repository

No response

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 4 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kubaflo commented 3 months ago

Hi, @AlleSchonWeg a quick fix to your issue would be to use data binding with x:reference

 <Border.StrokeShape>
    <RoundRectangle CornerRadius="{Binding BindingContext.Corner, Source={x:Reference Self}}" />
</Border.StrokeShape>