I want to use CarouselPage to have the right-to-left transition animation.
Could you please help me disable getsures in CarouselPage? I can't do that.
Thanks.
Setting InputTransparent of the CarouselPage will do the thing:
public App ()
{
MainPage = new CarouselPage{
InputTransparent = true, //This!
Children = {
new ContentPage{
Content = new Label{
Text = "Page 1",
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
}
},
new ContentPage{
Content = new Label{
Text = "Page 2",
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
}
}
}
};
}
Related
Xamarin.Forms on Android. I have scrollView with stack inside. Scroll works, but scrollBar not visible. I've tried to write custom renders but it didn't help.
My code: https://github.com/FeduniakVitalii/ScrollView
var contentAndWebViewLayout = new StackLayout() { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand};
contentAndWebViewLayout.Children.Add(contentLayout);
contentAndWebViewLayout.Children.Add(webView);
ScrollView scrollView = new ScrollView()
{
Content = contentAndWebViewLayout,
IsEnabled = true,
IsVerticalScrollbarEnabled = true,
IsClippedToBounds = true,
VerticalScrollBarVisibility = ScrollBarVisibility.Always,
VerticalOptions = LayoutOptions.FillAndExpand,
};
var converter = new HtmlLabelConverter();
var layout = new RelativeLayout()
{
BackgroundColor = Color.White,
VerticalOptions = LayoutOptions.FillAndExpand
};
layout.Children.Add(scrollView,
xConstraint: Constraint.Constant(0),
yConstraint: Constraint.Constant(0),
widthConstraint: Constraint.RelativeToParent((parent) => { return parent.Width; }),
heightConstraint: Constraint.RelativeToParent((parent) => { return parent.Height; }));
this.Content = layout;
I tried to downgrade Xamarin.Forms version to 3.4, problem solved !
i Am trying to create a survey form dynamically.Below is my code in view model.
I am adding the data to a grid and then to a stack layout.
foreach (var item in Settings.VOCQuestionDetailsSettings.RespondantQuestionnare)
{
myGrid.Children.Add(new Label { Text = item.Questions, TextColor = Color.Black, HorizontalOptions = LayoutOptions.FillAndExpand, FontAttributes = FontAttributes.Bold }, 0, rowCount);
rowCount++;
for (int i = 0; i < item.Choices.Count; i++)
{
if (item.QuestionType == "Radio")
{
myGrid.Children.Add(new CustomRadioButton
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Text = item.Choices[i],
TextColor = Color.Black,
FontSize = 14,
}, 0, rowCount);
rowCount++;
}
}
}
IF The question type is radio i am displaying the radio buttons.However now i need to disable other radio options if i select one.
I'm adding 2 children to a Grid like this:
private void pInitStackLayout()
{
grid1 = new Grid()
{
};
grid2 = new Grid()
{
};
biggrid = new Grid()
{
BackgroundColor = Color.Transparent,
Margin = new Thickness(0),
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.StartAndExpand,
Orientation = StackOrientation.Vertical,
};
biggrid.Children.Add(grid1,0,0);
biggrid.Children.Add(grid2,0,1);
this.Content = biggrid;
}
The ContentPage's (which is a Navigation Page) Content is the biggrid.
I would like to make it so that grid1 takes up 80% of the available height, and grid2 takes up 20% (or the rest).
How could I achieve this?
It's very simple actually, just set the RowDefinitions of biggrid.
// RowDefinitions isolated
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = new GridLength(8, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }
}
// RowDefinitions isolated
// Actual code
private void pInitStackLayout()
{
grid1 = new Grid()
{
};
grid2 = new Grid()
{
};
biggrid = new Grid()
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = new GridLength(8, GridUnitType.Star) },
new RowDefinition { Height = new GridLength(2, GridUnitType.Star) }
},
BackgroundColor = Color.Transparent,
Margin = new Thickness(0),
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.StartAndExpand,
Orientation = StackOrientation.Vertical,
};
biggrid.Children.Add(grid1,0,0);
biggrid.Children.Add(grid2,0,1);
this.Content = biggrid;
}
I have a StackLayout holding some elements for a custom cell in a ListView. The problem I am running in to is that my images are not landing on full pixel boundaries. This is causing the straight lines in my graphics to become blurry as they are not landing on pixel boundaries. Is there a way for me to easily prevent this behavior, perhaps in a custom renderer?
public InputEditCell()
{
image = new Image { HorizontalOptions = LayoutOptions.Start };
image.SetBinding(Image.SourceProperty, new Binding("Image.ImageNameSelect"));
image.BindingContext = _tempInputViewModel;
var tappedImageGesture = new TapGestureRecognizer
{
Command = new Command(OnImageTapped),
CommandParameter = image
};
image.GestureRecognizers.Add(tappedImageGesture);
nameEntry = new Entry()
{
TextColor = Color.FromHex("E60006"),
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry)),
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.FillAndExpand
};
nameEntry.SetBinding(Entry.TextProperty, "Name");
nameEntry.BindingContext = _tempInputViewModel;
var acceptImage = new Image
{
Source = ResourceHandler.GetAcceptImage(),
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.End,
};
var tappedAcceptGesture = new TapGestureRecognizer
{
Command = new Command(OnAcceptTapped),
CommandParameter = acceptImage
};
acceptImage.GestureRecognizers.Add(tappedAcceptGesture);
var cancelImage = new Image
{
Source = ResourceHandler.GetCancelImage(),
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.End,
};
var tappedCancelGesture = new TapGestureRecognizer
{
Command = new Command(OnCancelTapped),
CommandParameter = cancelImage
};
cancelImage.GestureRecognizers.Add(tappedCancelGesture);
var viewLayout = new StackLayout {
Orientation = StackOrientation.Horizontal,
Children = { image, nameEntry, acceptImage, cancelImage },
Padding = new Thickness(10, 10, 10 ,10)
};
View = viewLayout;
View.GestureRecognizers.Clear();
View.GestureRecognizers.Add(new TapGestureRecognizer());
}
I know there are many about this topic (Scroll horizontally in Xamarin.Forms ScrollView), but I could not implement the horizontal scrollview which scrolls horizontally.
public class DetailView : ContentPage
{
public DetailView ()
{
StackLayout stack = new StackLayout {
Orientation = StackOrientation.Horizontal,
};
for (int i = 0; i < 40; i++)
stack.Children.Add (new Button { Text = "Button" });
var scrollView = new ScrollView
{
Orientation = ScrollOrientation.Horizontal,
Content = stack
};
Content = scrollView;
}
}
Any ideas?
try this:
public DetailView()
{
var scrollableContent = new StackLayout()
{
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Fill,
Children =
{
new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Red},
new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Green},
new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Blue},
new BoxView(){HeightRequest=40, WidthRequest=40, BackgroundColor = Color.Maroon},
}
};
Content = new ScrollView()
{
HorizontalOptions = LayoutOptions.FillAndExpand,
Orientation = ScrollOrientation.Horizontal,
Content = scrollableContent,
};
}