question

65010773 avatar image
0 Votes"
65010773 asked FayWang-MSFT commented

how to bind with and height of relative panel

Hi

I have a relative panel named board located inside a relative panel .
the size of board is set only at realtime
here the xaml

  <RelativePanel x:Name ="Boardgame" RelativePanel.AlignVerticalCenterWithPanel="True" RelativePanel.AlignHorizontalCenterWithPanel="True"
          Margin="20,0,0,0" CornerRadius="6,6,6,6" Width="{x:Bind Path= widthboard }" Height="{x:Bind Path= widthboard }"  >
             <RelativePanel.Background>
                 <ImageBrush ImageSource ="/Assets/patternwood.jpg" Stretch="UniformToFill"/>
             </RelativePanel.Background>

         </RelativePanel>


i tried to bind the width and height to widthboard
widthboard is set in mainpagexaml.vb

When i run the app Boardgame has width = 0

Thanks

windows-uwp
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

When I tested your code and set a value to widthboard property in code-behind, the width and height of Boardgame worked well, they didn't return 0. Can you provide a simple sample that can be reproduced for us to test?

0 Votes 0 ·

Could you post c# code where you set property "widthboard" and the property definition?

0 Votes 0 ·

1 Answer

65010773 avatar image
0 Votes"
65010773 answered FayWang-MSFT commented


When I tested your code and set a value to widthboard property in code-behind

I wrote in the mainloading event widthboard = 60

Probably i don't understand how the xaml works ?
That exactly the problem where in the code behind i have to set widthboard so that when the xaml Width="{x:Bind Path= widthboard is applied get the value

Thanks

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So when you set the widthboard as 60 in the Loading event, can the Width of Boardgame worked well?

0 Votes 0 ·

It works
The mistake was the background

0 Votes 0 ·

If you have solved your issue, you could mark your answer to help others who have the same issue.

0 Votes 0 ·