Question about Padding / Margin - very picky?
boris-df opened this issue · comments
Hi,
i wonder why this class is so picky about setting Padding and Margin to relative high values?
Say I put this into a ViewCell and do this:
<context:SideContextMenuView IsAutoCloseEnabled="True">
<context:SideContextMenuView.View>
<Grid BackgroundColor="LightBlue"
WidthRequest="{Binding Source={x:Reference stackMain}, Path=Width, Converter={StaticResource MenuFitWidthConverter}, ConverterParameter='70'}"
Padding="20,5" Margin="15,5">
<Label Text="{Binding Text1}" TextColor="Black" FontSize="16"/>
</Grid>
</context:SideContextMenuView.View>
<!-- the context menu -->
<context:SideContextMenuView.ContextTemplate>
<DataTemplate>
<Frame Margin="0, 0"
Padding="0"
CornerRadius="0"
HasShadow="False"
IsClippedToBounds="true"
BackgroundColor="Gold">
<StackLayout>
<Label Text="Entfernen"
WidthRequest="150"/>
</StackLayout>
</Frame>
</DataTemplate>
</context:SideContextMenuView.ContextTemplate>
</context:SideContextMenuView>
It works.
But if i change the Padding / Margin of the Grid from "20,5" / "15,5" to something less, it stops working - i cannot slide the view to left to show the contextmenu anymore
So: Padding / Margin of "0" / "0" doesnt work. neither do "5" / "5" or "5, 5" / "0" etc.
I even tried to set the Padding higher than the Margin like "6,6" / "5" - nothing.
I think i didn't understand it fully :)
So i wonder if there is a rule for this to work? Is there way to have a ViewCell-Content having no border (full height/width) with this contextmenu working?
Thank you :)
Hi) You can use any value you want, but the total sum of padding/margin should be passed to the converter
WidthRequest="{Binding Source={x:Reference stackMain},
Path=Width,
Converter={StaticResource MenuFitWidthConverter},
ConverterParameter='70'}"
For example, here we pass 70 because Margin="15,5" Padding="20, 5"
Margin Left = 15, Margin Right = 15 (it total 15 + 15 = 30)
Padding Left = 20, Paddight Right = 20 (it total 20 + 20 = 40)
Grand Total = 30 + 40 = 70
So, if you want to change it to Marging="5", Padding="5" for example, then just pass 20 as parameter to MenuFitWidthConverter
I hope it helpes
Oh, i see! Thank you for this explanation. I'll try this! :)