本文整理汇总了C#中Entry.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# Entry.Focus方法的具体用法?C# Entry.Focus怎么用?C# Entry.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry.Focus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KaazingDemoLoginPage
public KaazingDemoLoginPage(KaazingJMSDemoController controller)
{
_controller = controller;
#region Set some properties on the Page
Padding = new Thickness(20);
Title = "Login";
HeightRequest = 200;
WidthRequest = 400;
#endregion
#region Create some Entry controls to capture username and password.
Entry loginInput = new Entry { Placeholder = "User Name" };
loginInput.SetBinding(Entry.TextProperty, "UserName");
loginInput.Focus();
Entry passwordInput = new Entry { IsPassword = true, Placeholder = "Password" };
passwordInput.SetBinding(Entry.TextProperty, "Password");
#endregion
#region Create a button to login with
Button loginButton = new Button {
Text = "Login",
BorderRadius = 5,
TextColor = Color.White,
BackgroundColor = Colours.BackgroundGrey
};
loginButton.SetBinding(BackgroundColorProperty, new Binding("LoginButtonColour"));
loginButton.Command = new Command(o => {
_controller.SetUsernameAndPassword(loginInput.Text, passwordInput.Text);
this.Navigation.PopModalAsync();
});
loginInput.Focus();
#endregion
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Children = {
loginInput,
passwordInput,
loginButton
},
Spacing = 10,
};
}
示例2: Init
protected override void Init ()
{
var entry = new Entry ();
var editor = new Editor();
var focuseEntryButton = new Button { Text = "Start Entry" };
var focuseEditorButton = new Button { Text = "Start Editor" };
focuseEntryButton.Clicked += (sender, args) => { entry.Focus (); };
focuseEditorButton.Clicked += (sender, args) => { editor.Focus (); };
var entryLabel = new Label { Text = "Type 123A into the Entry below; the entry should display '123'. If the 'A' is displayed, the test has failed. If the cursor resets to the beginning of the Entry after typing 'A', the test has failed." };
var editorLabel = new Label { Text = "Type 123A into the Editor below; the entry should display '123'. If the 'A' is displayed, the test has failed. If the cursor resets to the beginning of the Editor after typing 'A', the test has failed." };
entry.TextChanged += (sender, args) => {
var e = sender as Entry;
int val;
if(string.IsNullOrEmpty (args.NewTextValue?.Trim ())) {
return;
}
// check if this is numeric
if(!int.TryParse (args.NewTextValue, out val)) {
// put the old value back.
e.Text = args.OldTextValue;
}
};
editor.TextChanged += (sender, args) => {
var e = sender as Editor;
int val;
if(string.IsNullOrEmpty (args.NewTextValue?.Trim ())) {
return;
}
// check if this is numeric
if(!int.TryParse (args.NewTextValue, out val)) {
// put the old value back.
e.Text = args.OldTextValue;
}
};
// Initialize ui here instead of ctor
Content = new StackLayout {
Children = { focuseEntryButton, entryLabel, entry, focuseEditorButton, editorLabel, editor }
};
}
示例3: Init
protected override void Init()
{
Title = "focus test";
var editor = new Editor();
var entry = new Entry();
editor.Unfocused += (object sender, FocusEventArgs e) => entry.Focus();
Content = new StackLayout
{
Children =
{
editor,
entry
}
};
}
示例4: InitializeSearchLayout
private void InitializeSearchLayout()
{
mSearchLayout = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(640),
HeightRequest = MyDevice.GetScaledSize(73),
BackgroundColor = Color.FromRgb(27,184,105)
};
SearchEntry = new Entry () {
WidthRequest = MyDevice.GetScaledSize(640),
HeightRequest = MyDevice.GetScaledSize(73),
Text = "Search",
TextColor = Color.White,
FontSize = MyDevice.FontSizeMedium,
HorizontalTextAlignment = TextAlignment.Start
};
var searchImage = new Image () {
WidthRequest = MyDevice.GetScaledSize(583),
HeightRequest = MyDevice.GetScaledSize(52),
Source = "ProductsPage_SearchBar.png"
};
var searchButton = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(444),
HeightRequest = MyDevice.GetScaledSize(51)
};
var deleteButton = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(69),
HeightRequest = MyDevice.GetScaledSize(51)
};
var backButton = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(65),
HeightRequest = MyDevice.GetScaledSize(72)
};
var searchEntryTapRecognizer= new TapGestureRecognizer ();
searchEntryTapRecognizer.Tapped += (sender, e) => {
SearchEntry.Focus();
};
searchButton.GestureRecognizers.Add(searchEntryTapRecognizer);
var deleteButtonTapRecognizer= new TapGestureRecognizer ();
deleteButtonTapRecognizer.Tapped += (sender, e) => {
SearchEntry.Text = "";
};
deleteButton.GestureRecognizers.Add(deleteButtonTapRecognizer);
var backButtonTapRecognizer= new TapGestureRecognizer ();
backButtonTapRecognizer.Tapped += (sender, e) => {
if( mParent.mBrowseProductPage != null )
mParent.LoadProductsPage(mParent.mBrowseProductPage.mProductDictionary,mParent.mBrowseProductPage.mCategory);
else
mParent.SwitchTab("BrowseCategories");
};
backButton.GestureRecognizers.Add(backButtonTapRecognizer);
mMidLayout.Children.Add (mSearchLayout,
Constraint.Constant(0),
Constraint.RelativeToView (mTopLayout, (parent, sibling) => {
return sibling.Bounds.Bottom + MyDevice.GetScaledSize (1);
})
);
mMidLayout.Children.Add (searchImage,
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Left + MyDevice.GetScaledSize (28);
}),
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Top + MyDevice.GetScaledSize (10);
})
);
mMidLayout.Children.Add (SearchEntry,
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Left + MyDevice.GetScaledSize (136);
}),
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Top + MyDevice.GetScaledSize (5);
})
);
mMidLayout.Children.Add (searchButton,
Constraint.RelativeToView (searchImage, (parent, sibling) => {
return sibling.Bounds.Left;
}),
Constraint.RelativeToView (searchImage, (parent, sibling) => {
return sibling.Bounds.Top;
})
);
mMidLayout.Children.Add (deleteButton,
Constraint.RelativeToView (searchImage, (parent, sibling) => {
return sibling.Bounds.Right - MyDevice.GetScaledSize (67);
}),
//.........这里部分代码省略.........
示例5: KaazingJMSDemoPage
public KaazingJMSDemoPage()
{
_controller = new KaazingJMSDemoController(this);
Title = "KaazingJMSXamarinDemo";
BackgroundColor = Color.FromRgb(255, 140, 0);
uriEntry = new Entry {
HorizontalOptions = LayoutOptions.FillAndExpand,
MinimumHeightRequest = 5,
HeightRequest = 5,
Text = "ws://localhost:8001/jms",
//Text = "ws://192.168.0.109:8001/jms",
};
uriEntry.Focus();
destinationEntry = new Entry {
HorizontalOptions = LayoutOptions.FillAndExpand,
HeightRequest = 8,
Text = "/topic/destination"
};
messageEntry = new Entry {
HorizontalOptions = LayoutOptions.FillAndExpand,
HeightRequest = 8,
Text = "Hello Kaazing!"
};
connectButton = new Button {
Text = "Connect",
BindingContext = this,
};
connectButton.Clicked += _controller.ConnectOrDisconnect;
subscribeButton = new Button {
Text = "Subscribe",
BindingContext = this,
};
subscribeButton.Clicked += _controller.Subscribe;
sendButton = new Button {
Text = "Send",
BindingContext = this,
};
sendButton.Clicked += _controller.SendMessage;
clearButton = new Button {
Text = "Clear",
BindingContext = this,
};
clearButton.Clicked += _controller.ClearLog;
logLabel = new Label {
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.End,
TextColor = Color.Black
};
// Create a grid to hold the Labels & Entry controls.
Grid inputGrid = new Grid {
ColumnDefinitions = {
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
},
Children = { {
new Label {
Text = "URI:",
XAlign = TextAlignment.End,
Font = Fonts.SmallTitle,
TextColor = Colours.SubTitle
},0,0
}, {
new Label {
Text = "Destination:",
XAlign = TextAlignment.End,
Font = Fonts.SmallTitle,
TextColor = Colours.SubTitle
}, 0,1
}, {
new Label {
Text = "Message: ",
XAlign = TextAlignment.End,
Font = Fonts.SmallTitle,
TextColor = Colours.SubTitle
},0, 2
},
{ uriEntry, 1, 0 },
{ destinationEntry, 1, 1 },
{ messageEntry, 1, 2 },
{ connectButton, 3, 0},
{ subscribeButton, 3, 1},
{ sendButton, 3, 2}
}
};
inputGrid.Padding = new Thickness(10);
var logView = new ScrollView {
Content = new StackLayout {
//.........这里部分代码省略.........
示例6: InitializeSearchLayout
private void InitializeSearchLayout()
{
mSearchLayout = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(640),
HeightRequest = MyDevice.GetScaledSize(73),
BackgroundColor = Color.FromRgb(27,184,105)
};
SearchEntry = new Entry () {
WidthRequest = MyDevice.GetScaledSize(640),
HeightRequest = MyDevice.GetScaledSize(73),
Text = "Search",
TextColor = Color.White,
FontSize = MyDevice.FontSizeMedium,
HorizontalTextAlignment = TextAlignment.Start
};
var searchImage = new CachedImage () {
WidthRequest = MyDevice.GetScaledSize(583),
HeightRequest = MyDevice.GetScaledSize(52),
Source = "ProductsPage_SearchBar.png",
CacheDuration = TimeSpan.FromDays(30),
DownsampleToViewSize = true,
RetryCount = 10,
RetryDelay = 250,
TransparencyEnabled = false,
FadeAnimationEnabled = false
};
var searchButton = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(444),
HeightRequest = MyDevice.GetScaledSize(51)
};
var deleteButton = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(69),
HeightRequest = MyDevice.GetScaledSize(51)
};
var backButton = new RelativeLayout () {
WidthRequest = MyDevice.GetScaledSize(65),
HeightRequest = MyDevice.GetScaledSize(72)
};
var searchEntryTapRecognizer= new TapGestureRecognizer ();
searchEntryTapRecognizer.Tapped += (sender, e) => {
SearchEntry.Focus();
};
searchButton.GestureRecognizers.Add(searchEntryTapRecognizer);
var deleteButtonTapRecognizer= new TapGestureRecognizer ();
deleteButtonTapRecognizer.Tapped += (sender, e) => {
if( SearchEntry.Text.Length > 0 )
SearchEntry.Text = SearchEntry.Text.Remove(SearchEntry.Text.Length - 1);
};
deleteButton.GestureRecognizers.Add(deleteButtonTapRecognizer);
var backButtonTapRecognizer= new TapGestureRecognizer ();
backButtonTapRecognizer.Tapped += (sender, e) => {
mParent.SwitchTab ("BrowseCategories");
};
backButton.GestureRecognizers.Add(backButtonTapRecognizer);
mMidLayout.Children.Add (mSearchLayout,
Constraint.Constant(0),
Constraint.RelativeToView (mTopLayout, (parent, sibling) => {
return sibling.Bounds.Bottom + MyDevice.GetScaledSize (1);
})
);
mMidLayout.Children.Add (searchImage,
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Left + MyDevice.GetScaledSize (28);
}),
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Top + MyDevice.GetScaledSize (10);
})
);
mMidLayout.Children.Add (SearchEntry,
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Left + MyDevice.GetScaledSize (136);
}),
Constraint.RelativeToView (mSearchLayout, (parent, sibling) => {
return sibling.Bounds.Top + MyDevice.GetScaledSize (5);
})
);
mMidLayout.Children.Add (searchButton,
Constraint.RelativeToView (searchImage, (parent, sibling) => {
return sibling.Bounds.Left;
}),
Constraint.RelativeToView (searchImage, (parent, sibling) => {
return sibling.Bounds.Top;
})
);
//.........这里部分代码省略.........
示例7: UserLoginPage
public UserLoginPage()
: base("Phoenix Imperator")
{
BackgroundColor = Color.Black;
AddLogo ();
string headerText;
if (Phoenix.Application.UserManager.Count () < 1) {
headerText = "Setup your account";
} else {
headerText = "Phoenix Imperator";
}
header = AddHeading (headerText);
statusMessage = new Label {
XAlign = TextAlignment.Center,
Text = "",
TextColor = Color.Silver
};
userIdEntry = new Entry {
Placeholder = "User ID",
HorizontalOptions = LayoutOptions.FillAndExpand,
Keyboard = Keyboard.Numeric,
};
userCodeEntry = new Entry {
Placeholder = "Code",
HorizontalOptions = LayoutOptions.FillAndExpand
};
userIdEntry.Focus ();
loginButton = new Button {
Text = "Login",
Font = Font.SystemFontOfSize(NamedSize.Large),
FontAttributes = FontAttributes.Bold,
TextColor = Color.Black,
BackgroundColor = Color.White,
BorderWidth = 1,
HorizontalOptions = LayoutOptions.FillAndExpand
};
loginButton.Clicked += LoginButtonClicked;
Button linkButton = new Button {
HorizontalOptions = LayoutOptions.CenterAndExpand,
Text = "Visit Nexus to get your XML Access Id and Code",
// TextColor = Color.White,
// BackgroundColor = Color.Black
};
linkButton.Clicked += LinkButtonClicked;
PageLayout.Children.Add (userIdEntry);
PageLayout.Children.Add (userCodeEntry);
PageLayout.Children.Add (loginButton);
PageLayout.Children.Add (linkButton);
PageLayout.Children.Add (statusMessage);
int userCount = Phoenix.Application.UserManager.Count ();
Log.WriteLine (Log.Layer.AL, GetType(), "Users: " + userCount);
if (userCount > 0) {
Phoenix.Application.UserManager.First ((user) => {
Device.BeginInvokeOnMainThread (() => {
linkButton.IsEnabled = false;
linkButton.IsVisible = false;
});
UserCode = user.Code;
UserId = user.Id;
Phoenix.Application.UserLoggedIn(user);
});
}
}
示例8: HomeToBorderDistancePopup
/// <summary>
/// Creates a view for the HomeToBorderDistance popup
/// </summary>
/// <returns>Stacklayout of the popup content</returns>
public StackLayout HomeToBorderDistancePopup()
{
var display = Resolver.Resolve<IDevice>().Display;
var header = new Label
{
Text = HomeToBorderDistanceText,
TextColor = Color.FromHex(Definitions.TextColor),
FontSize = Definitions.HeaderFontSize,
HorizontalOptions = LayoutOptions.FillAndExpand,
YAlign = TextAlignment.Center,
XAlign = TextAlignment.Center,
};
var headerstack = new StackLayout
{
Orientation = StackOrientation.Horizontal,
BackgroundColor = Color.FromHex(Definitions.PrimaryColor),
HorizontalOptions = LayoutOptions.FillAndExpand,
HeightRequest = Definitions.HeaderHeight,
Children =
{
header,
}
};
var text = new Label
{
Text = "Rediger i antal kørte km: ",
TextColor = Color.FromHex(Definitions.DefaultTextColor),
FontSize = Definitions.PopupTextSize,
HorizontalOptions = LayoutOptions.Center,
YAlign = TextAlignment.Center,
};
var entry = new Entry
{
TextColor = Color.FromHex(Definitions.DefaultTextColor),
Keyboard = Keyboard.Numeric,
HorizontalOptions = LayoutOptions.FillAndExpand,
};
entry.SetBinding(Entry.TextProperty, FinishDriveViewModel.HomeToBorderDistanceProperty);
entry.Focus();
var noButton = new ButtomButton("Fortryd", () => PopUpLayout.DismissPopup());
var noStack = new StackLayout
{
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.Start,
HeightRequest = Definitions.ButtonHeight,
WidthRequest = _yesNoButtonWidth,
Children = { noButton }
};
var yesButton = new ButtomButton("Gem", SendHomeToBorderDistanceMessage);
var yesStack = new StackLayout
{
VerticalOptions = LayoutOptions.End,
HorizontalOptions = LayoutOptions.End,
HeightRequest = Definitions.ButtonHeight,
WidthRequest = _yesNoButtonWidth,
Children = { yesButton }
};
var ButtonStack = new StackLayout
{
BackgroundColor = Color.White, // for Android and WP
Orientation = StackOrientation.Horizontal,
VerticalOptions = LayoutOptions.End,
Padding = new Thickness(Definitions.Padding, 0, Definitions.Padding, Definitions.Padding),
Spacing = Definitions.Padding,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children =
{
noStack,
yesStack
}
};
var PopUp = new StackLayout
{
WidthRequest = _popupWidth,
BackgroundColor = Color.White,
Orientation = StackOrientation.Vertical,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Spacing = Definitions.Padding,
Children =
{
headerstack,
text,
entry,
ButtonStack
}
};
var topPadding = display.Height / 2 - 150;
var PopUpBackground = new StackLayout
//.........这里部分代码省略.........
示例9: SettingsPage
public SettingsPage (bool firstTimePrompt)
{
if (firstTimePrompt) {
title.Text = "Welcome. Please enter your name and tap 'Save'";
} else {
title.Text = "Update Settings";
}
// see if the following puts the "back arrow" on Droid:
// NavigationPage.SetHasNavigationBar (this, true);
Padding = new Thickness (5, Device.OnPlatform (20, 0, 0), 5, 0);
var entryStyle = new Style (typeof(Entry)) {
Setters = {
new Setter { Property = Entry.FontAttributesProperty, Value = FontAttributes.Bold, },
new Setter { Property = Entry.FontSizeProperty, Value = 22, },
}
};
var nameLabel = new Label () {
Text = "Name:",
};
nameEntry = new Entry { Style = entryStyle, };
nameEntry.SetBinding (Entry.TextProperty, "Name");
if (String.IsNullOrWhiteSpace (nameEntry.Text))
nameEntry.Placeholder = "Please enter your name";
var nameStack = new StackLayout () {
Orientation = StackOrientation.Vertical,
Children = { nameLabel, nameEntry }
};
var greenThresholdLabel = new Label () {
Text = "Red-to-green Score threshold:",
//WidthRequest = 200
};
var greenThresholdEntry = new Entry { Keyboard = Keyboard.Numeric, Style = entryStyle, };
greenThresholdEntry.SetBinding (Entry.TextProperty, "GreenThreshold");
var greenStack = new StackLayout () {
Orientation = StackOrientation.Horizontal,
Children = { greenThresholdLabel, greenThresholdEntry }
};
var saveButton = new Button { Text = "Save", BorderWidth = 2, };
saveButton.Clicked += (sender, e) => {
var settings = (Settings)BindingContext;
App.Database.SaveSettings (settings);
if (firstTimePrompt) {
var startPage = new StartPage();
var rootPage = new NavigationPage(startPage);
this.Navigation.PushModalAsync (rootPage);
//this.Navigation.PushModalAsync (new StartPage ());
} else {
MessagingCenter.Send<SettingsPage>(this, "popped");
this.Navigation.PopModalAsync();
}
};
var cancelButton = new Button { Text = "Cancel", BorderWidth = 2, };
cancelButton.Clicked += (sender, e) => {
this.Navigation.PopModalAsync();
//this.Navigation.PopAsync ();
};
var resetButton = new Button {
Text = "Clear Entire Database", TextColor = Color.Red, BorderWidth = 2,
};
resetButton.Clicked += async (sender, e) => {
var action = await DisplayActionSheet ("Are you sure you want to delete all data?",
"No", "Yes, wipe clean!");
if (action.StartsWith ("N"))
return;
App.Database.DeleteAll ();
MessagingCenter.Send<SettingsPage>(this, "popped");
this.OnAppearing ();
};
if (firstTimePrompt) {
nameEntry.Focus ();
Content = new StackLayout {
Children = {
title,
nameStack,
saveButton,
}
};
} else {
Content = new StackLayout {
//Padding = new Thickness (5),
Children = {
title,
nameStack,
greenStack,
//starIncrementStack,
saveButton,
cancelButton,
resetButton,
}
};
}
//.........这里部分代码省略.........