I'm trying to create simple black border for a label in Xamarin forms. It seems anything inside a frame is not visible.
Here is my code:
<Frame BorderColor="Black"
CornerRadius="0">
<Label x:Name="txtText"
Text="Here"
TextColor="Black"
BackgroundColor="White"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
HorizontalTextAlignment="Center" />
</Frame>
I can set the background property in my frame to anything and that works OK, I even tried setting it to transparent with no success.
This is what I see with the code above.
I'm using Visual Studio 2017 and Android if that helps.
UPDATE
I've found a solution, but it seems hacky. I've put it all inside a StackLayout, set the request height of the frame to 100 and set the padding to 1.
Here is the updated code:
<StackLayout>
<Frame BorderColor="{DynamicResource PrimaryColour}"
CornerRadius="0"
Padding="1"
HeightRequest="100">
<Label x:Name="txtText"
Text="Here"
TextColor="{DynamicResource PrimaryColour}"
BackgroundColor="{DynamicResource SecondaryColour}"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"/>
</Frame>
</StackLayout>
The Xamarin. Forms Frame class is a layout used to wrap a view with a border that can be configured with color, shadow, and other options. Frames are commonly used to create borders around controls but can be used to create more complex UI.
Frame takes some default padding of 20 ,so if frame is really small then elements inside it will never show.
So,just make padding="0"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With