I am creating a rounded menu with Xamarin Forms as Below.
The accent color is my Grid. Then I translatex and trnaslatey the buttons.
My issue is that the click button is not raised. I have also tried on the gesture recognizer of my stack panel. Same result.
The part of the code is below:
<Grid BackgroundColor="Accent" Margin="0,0,0,10" VerticalOptions="End" HorizontalOptions="Center">
<StackLayout x:Name="cat" TranslationX="-109" TranslationY="-102"
>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="catBtn_Clicked"/>
</StackLayout.GestureRecognizers>
<Button Clicked="catBtn_Clicked" WidthRequest="60"
HeightRequest="60"
FontSize="35"
CornerRadius="30" HorizontalOptions="Center"
BackgroundColor="{StaticResource RedColor}"
TextColor="White"
Text="{ x:Static local:GrialIconsFont.Calendar }"
FontFamily="{ StaticResource IconsFontFamily }">
</Button>
<Label Text="{extensions:Translate Hello}" HorizontalOptions="Center"/>
</StackLayout>
Make sure that your button is placed inside superView's bounds,
If a button is placed outside superView's bounds, the button will not clickable.
You use TranslationX="-109" and TranslationY="-102" will make the button out of the bounds of StackLayout, so it won't response to the click event. You can add backgroundColor to stacklayout to see its bounds.
I would suggest you to add those buttons or labels directly to Grid and use absolute-layout, relative-layout or other layout to fix their positions.
There are also some examples in Github you can refer, such as CircleButtonMenu, Xamarin.Forms-RadialMenu
Related
I use the below code to show image on a from.
<ContentPage>
<ContentPage.Content>
<Grid>
// Row definitions here
// Column definitions here
<Image
Grid.Column="0"
Grid.Row="0"
x:Name="myStoryPage"
Grid.ColumnSpan="3">
</Image>
<!-- Next, previous buttons here -->
<skiaforms:SKCanvasView x:Name="canvasView"
PaintSurface="canvasView_PaintSurface"
Grid.Row="3"
Grid.Column="0"
Grid.ColumnSpan="3"
AbsoluteLayout.LayoutBounds="10, 0, 5, 65"/>
</Grid>
</ContentPage.Content>
</ContentPage>
Now I need to highlight an area in the image using SkiaSharp.
I could do drawing a line under the grid using the SKCanvasView. But I want to draw over the image.
I thought to use use AbsoluteLayout but as my page is a ContentPage, I could not use the AbsoluteLayout outside of the content.
If I could use AbsoluteLayout, I can dynamically position it using C# in code behind.
I have a control in Xamarin Forms where I have a bunch of labels that are visible or invisible based on a few factors.
I want the layout I'm calling the control from to wrap the height based on the labels that are visible. So if the labels are 100dp tall for example (I don't actually know how tall they are) and there are 3 visible, I want the height of the control/layout to be 300dp. Right now the layout is just stretching out to what it would look like if all the labels were visible.
This is my control:
<controls:cardDetail>
<Label Text="hi1" IsVisible="{Binding maybe1}">
<Label Text="hi2" IsVisible="{Binding maybe2}">
<Label Text="hi3" IsVisible="{Binding maybe3}">
<Label Text="hi4" IsVisible="{Binding maybe4}">
<Label Text="hi5" IsVisible="{Binding maybe5}">
<Label Text="hi6" IsVisible="{Binding maybe6}">
</controls:cardDetail>
I call this control from a carousel view inside a stacklayout in another xaml page:
<StackLayout orientation="Horizontal">
<CarouselView x:Name="carView">
<controls:cardDetail/>
</CarouselView>
</StackLayout>
What do I have to do to which page/layout to make this happen? Do I need to use C# or can I just add an attribute in xaml??
Thanks!
In Xamarin Forms 4.1, When scroll, scrollview content is covering/overflow the headerview and scrollview content is not shown completely.
Tried with IsClippedToBounds to true.
Created scrollviewrenderer, OnDraw() -> set clip to bound property. But didn't worked.
Example: Here is the XAML design
<Stacklayout>
<HeaderView/>
<ScrollView IsClippedToBounds="true">
<Stacklayout>
<label text="1"/>
........
........
<label text="100"/>
</Stacklayout>
</ScrollView>
</Stacklayout>
I make a custom control as the headerview in your description. And test on Xamarin.forms 4.1, works well.
MyCustomConrol:
<StackLayout Orientation="Horizontal" BackgroundColor="Aqua">
<Label x:Name="Title_label" Text="Title" TextColor="Black" FontSize="25" HorizontalOptions="StartAndExpand" Margin="8,0,4,0"/>
<Button x:Name="btnHello" Text="Hello" HorizontalOptions="EndAndExpand" Margin="4,0,8,0"/>
</StackLayout>
MainPage.xaml
<StackLayout>
<local:MyCustomControl></local:MyCustomControl>
<!--<HeaderView/>-->
<ScrollView IsClippedToBounds="true">
<StackLayout>
<Label Text="1"/>
<Label Text="2"/>
<Label Text="3"/>
……………
…………………
</StackLayout>
</ScrollView>
Result:
You could download from ScrollView/XamarinDemo folder of GitHub for reference.
https://github.com/WendyZang/Test.git
If you want your header to be always visible then rather than placinf your content in Header, it will be better to place your header content first then below that place your listview. Thus, your header remains intact and listview scrolls.
good day, I'm having a problem with a scroll view, I have a label in a horizontal scroll view, that label concateno amounts, the problem is when the text no longer fit on the screen, the scroll does not move, and I would like if I enter a new quantity in the label, the scroll scrolls so that the last added quantity can be visible, I hope you can help me
This is my XAML:
<ScrollView x:Name="SV" Orientation="Horizontal" HorizontalScrollBarVisibility="Never" HorizontalOptions="FillAndExpand">
<Label Text="{Binding FullSumList}" TextColor="#000000" FontSize="{extensions:ScalableFont 30}" VerticalOptions="EndAndExpand" HorizontalOptions="EndAndExpand" />
</ScrollView>
I searched, not to find a solution
there if I write a quantity, should the scroll go to the left, so that the new quantity is seen
You can use the ScrollToAsync method.
In your xaml
<ScrollView x:Name="SV" Orientation="Horizontal" HorizontalScrollBarVisibility="Never" HorizontalOptions="FillAndExpand">
<Label x:Name="labelTest" Text="{Binding FullSumList}" TextColor="#000000" FontSize="{extensions:ScalableFont 30}" VerticalOptions="EndAndExpand" HorizontalOptions="EndAndExpand" />
</ScrollView>
In the code-behind
SV.ScrollToAsync(labelTest, ScrollToPosition.End, true);
In my application, I have an image control with a scrollbar. so I want to zoom in and zoom out the image on (Plus, Minus) button click.
<ScrollViewer Name="scrollViewerimage"
VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible" Margin="42,10,19,259" Grid.Row="2" ViewChanged="ScrollViewerimage_ViewChanged" SizeChanged="ScrollViewerimage_SizeChanged">
<Image x:Name="DisplayImage" Stretch="None"
Margin="0,0,0,0" Width="647"
HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Height="585" Grid.Row="1" >
</Image>
</ScrollViewer>
Any help would be highly appreciated.