本文整理汇总了C#中Xamarin.Forms.StackLayout.TranslateTo方法的典型用法代码示例。如果您正苦于以下问题:C# StackLayout.TranslateTo方法的具体用法?C# StackLayout.TranslateTo怎么用?C# StackLayout.TranslateTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xamarin.Forms.StackLayout
的用法示例。
在下文中一共展示了StackLayout.TranslateTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DemoPage
public DemoPage()
{
this.Padding = 0;
var mainStack = new StackLayout () {
Padding = new Thickness(0,20,0,0),
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
};
listView = new ListView () {};
listView.ItemsSource = items;
mainStack.Children.Add (listView);
textEntry = new Entry () {
HorizontalOptions = LayoutOptions.FillAndExpand,
Placeholder = "Type something...",
};
var textStack = new StackLayout () {
Orientation = StackOrientation.Horizontal,
Padding = 10,
BackgroundColor = Color.White,
};
textStack.Children.Add (textEntry);
var textButton = new Button () {
Text = "Post",
FontAttributes = FontAttributes.Bold,
FontSize = 16,
HorizontalOptions = LayoutOptions.End,
};
textButton.Clicked += (object sender, EventArgs e) => {
System.Diagnostics.Debug.WriteLine ("listview height: " + listView.Height);
items.Add(textEntry.Text);
textEntry.Text = string.Empty;
listView.ScrollTo(items.Last(), ScrollToPosition.MakeVisible, true);
};
textStack.Children.Add (textButton);
mainStack.Children.Add (textStack);
// This works nicely with stacklayouts but causes issues on listviews as they automatically adjust their size
// var spacer = new BoxView () {
// HorizontalOptions = LayoutOptions.FillAndExpand,
// HeightRequest = 0,
// };
// mainStack.Children.Add (spacer);
KeyboardHelper.KeyboardChanged += (sender, e) => {
bottomOffset = mainStack.Bounds.Bottom - textStack.Bounds.Bottom; // This offset allows us to only raise the stack by the amount required to stay above the keyboard.
var ty = e.Visible ? -e.Height : -1;
textStack.TranslateTo(textStack.TranslationX, ty, e.Duration, Easing.CubicInOut);
// spacer.HeightRequest = e.Visible ? e.Height : -1;
};
this.Content = mainStack;
}
示例2: myimagomenu
public myimagomenu ()
{
//http://facchini-ts.it/imagobe/DATABASE/imagolight.txt
//HttpWebRequest a;
//HttpClient b = new HttpClient ();
currentPlataform = DependencyService.Get<platformSpecific> ();
b1 = new StackLayout {
BackgroundColor = Color.FromRgb (40, 40, 40),
//VerticalOptions = LayoutOptions.Center
};
b2 = new StackLayout {
BackgroundColor = Color.FromRgb (60, 60, 60),
};
b3 = new StackLayout {
BackgroundColor = Color.FromRgb (80, 80, 80),
};
btn1 = new Button (){ Text = "btn1" };
//b1.Children.Add (btn1);
btn2 = new Button (){ Text = "btn2" };
//b2.Children.Add (btn2);
#region "open"
btn1.Clicked += async delegate(object sender, EventArgs e) {
b2.IsVisible = true;
b3.IsVisible = false;
await b2.TranslateTo (0, -this.b1H);
};
btn2.Clicked += async delegate(object sender, EventArgs e) {
b1.IsVisible = false;
b2.IsVisible = true;
b3.IsVisible = true;
await b2.TranslateTo (0, 0);
await b3.TranslateTo (0, -this.b2H);
};
#endregion
#region "close"
var mygest = new TapGestureRecognizer ();
mygest.Tapped += async (object sender, EventArgs e) => {
//b2 b1
await b2.TranslateTo (0, 0);
b2.IsVisible = false;
};
b1.GestureRecognizers.Add (mygest);
var mygest2 = new TapGestureRecognizer ();
mygest2.Tapped += async (object sender, EventArgs e) => {
if (b1.IsVisible) {
//b2,b1
await b2.TranslateTo (0, 0);
} else {
//b3 b2
b3.IsVisible = false;
b1.IsVisible = true;
await b2.TranslateTo (0, -this.b1H);
}
};
b2.GestureRecognizers.Add (mygest2);
var mygest3 = new TapGestureRecognizer ();
mygest3.Tapped += async (object sender, EventArgs e) => {
//b3 b2
b3.IsVisible = false;
b1.IsVisible = true;
await b2.TranslateTo (0, -this.b1H);
};
b3.GestureRecognizers.Add (mygest3);
#endregion
al = new AbsoluteLayout ();
Content = al;
this.SizeChanged += async delegate(object sender, EventArgs e) {
var hMenu = this.Height;
hMenu += 1;
//568
var half = Convert.ToInt32 (hMenu / 2);
var delta = hMenu - (half * 2);
b1H = half;
//b3H += delta;
b2H = half - 100;
b3H = half - 200;
//.........这里部分代码省略.........
示例3: AddEventsSituationsOrThoughts
//.........这里部分代码省略.........
Image audioRecodeOnButton = new Image
{
BackgroundColor = Color.Transparent,
VerticalOptions = LayoutOptions.Center,
Source = Device.OnPlatform("mic.png", "mic.png", "//Assets//mic.png"),
};
audioRecodeOnHolder = new StackLayout
{
Padding = 10,
VerticalOptions = LayoutOptions.End,
Children = { audioRecodeOnButton }
};
TapGestureRecognizer RecodeOnTapRecognizer = new TapGestureRecognizer();
audioRecodeOnHolder.GestureRecognizers.Add(RecodeOnTapRecognizer);
audioRecodeOffButton = new Image
{
BackgroundColor = Color.Transparent,
VerticalOptions = LayoutOptions.Center,
Source = Device.OnPlatform("turn_off_mic.png", "turn_off_mic.png", "//Assets//turn_off_mic.png"),
};
audioRecodeOffHolder = new StackLayout
{
BackgroundColor = Color.Transparent,
Padding = 10,
VerticalOptions = LayoutOptions.End,
IsVisible = false,
Children = { audioRecodeOffButton }
};
TapGestureRecognizer RecodeOffTapRecognizer = new TapGestureRecognizer();
audioRecodeOffHolder.GestureRecognizers.Add(RecodeOffTapRecognizer);
audioRecodeOffHolder.TranslateTo(0, Device.OnPlatform(audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 50), 5, null);
audioRecodeOnHolder.TranslateTo(0, Device.OnPlatform(audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 60, audioRecodeOffButton.Y + 50), 5, null);
RecodeOnTapRecognizer.Tapped += RecodeOnTapRecognizer_Tapped;
RecodeOffTapRecognizer.Tapped += RecodeOffTapRecognizer_Tapped;
StackLayout menuPinContainer = new StackLayout
{
BackgroundColor = Color.White,
Orientation = StackOrientation.Vertical,
HeightRequest = 140,
WidthRequest = (int)(devWidth * .10),
Children = {
pinButtonHolder,
audioRecodeOnHolder,
audioRecodeOffHolder
}
};
TapGestureRecognizer locationlabelTap = new TapGestureRecognizer();
locationInfo = new Label();
locationInfo.TextColor = Constants.BLUE_BG_COLOR;
locationInfo.BackgroundColor = Color.Transparent;
locationInfo.FontSize = 12;
locationInfo.HeightRequest = Device.OnPlatform(15, 25, 25);
locationInfo.GestureRecognizers.Add(locationlabelTap);
locationlabelTap.Tapped += OnEditLocationInfo;
editLocationAndContactsStack = new StackLayout();
editLocationAndContactsStack.Padding = new Thickness(1, 1, 1, 1);
editLocationAndContactsStack.BackgroundColor = Color.FromRgb(30, 126, 210);
示例4: ApplyAnimation
private async Task<bool> ApplyAnimation( StackLayout layout )
{
await layout.TranslateTo(0, -30, 250, Easing.CubicOut);
await layout.TranslateTo(0, 0, 250, Easing.CubicOut);
return true;
}