///// <summary> ///// 将当前枚举类型转换为IList<EnumItem> ///// </summary> ///// <param name="_enum">枚举类型</param> ///// <returns></returns> //public static IList<EnumItem> ToListEnumItem(this Enum _enum) //{ // return ToListEnumItem(_enum, null); //} ///// <summary> ///// 将当前枚举类型转换为IList<EnumItem> ///// </summary> ///// <param name="_enum">枚举类型</param> ///// <param name="enumItem">默认第一项的设置[如:请选择xxx]</param> ///// <returns></returns> //public static IList<EnumItem> ToListEnumItem(this Enum _enum, EnumItem enumItem) //{ // return PrivateToListEnumItem(_enum, enumItem); //} //public static List<EnumItem> PrivateToListEnumItem(Enum _enu,EnumItem enumItem) //{ // List<EnumItem> enumList = new List<EnumItem>(); // Type enumType = _enu.GetType(); // FieldInfo[] fieldInfos = enumType.GetFields(); // foreach (FieldInfo fieldInfo in fieldInfos) // { // EnumItem item = new EnumItem(); // // 过滤掉一个不是枚举值的,记录的是枚举的源类型 // if (fieldInfo.FieldType.IsEnum == false) // continue; // // 通过字段的名字得到枚举的值 // item.EnumValue = ((int)enumType.InvokeMember(fieldInfo.Name, BindingFlags.GetField, null, null, null)).ToString(); // item.EnumKey = fieldInfo.Name; // object[] attrs = fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), true); // if (attrs != null && attrs.Length > 0) // { // EnumDescriptionAttribute desc = attrs[0] as EnumDescriptionAttribute; // if (desc != null) // { // item.EnumDescript = desc.Description; // } // } // enumList.Add(item); // } // if (enumItem != null) // { // enumList.Insert(0, enumItem); // } // return enumList; //} /// <summary> /// 将当前枚举类型转换为IList<EnumItem>-静态的方法调用 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="enumItem"></param> /// <returns></returns> public static List <EnumItem> ToListEnumItem <T>(EnumItem enumItem) { List <EnumItem> enumList = new List <EnumItem>(); Type enumType = typeof(T); FieldInfo[] fieldInfos = enumType.GetFields(); foreach (FieldInfo fieldInfo in fieldInfos) { EnumItem item = new EnumItem(); // 过滤掉一个不是枚举值的,记录的是枚举的源类型 if (fieldInfo.FieldType.IsEnum == false) { continue; } // 通过字段的名字得到枚举的值 item.EnumValue = ((int)enumType.InvokeMember(fieldInfo.Name, BindingFlags.GetField, null, null, null)).ToString(); item.EnumKey = fieldInfo.Name; object[] attrs = fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), true); if (attrs != null && attrs.Length > 0) { EnumDescriptionAttribute desc = attrs[0] as EnumDescriptionAttribute; if (desc != null) { item.EnumDescript = desc.Description; } } enumList.Add(item); } if (enumItem != null) { enumList.Insert(0, enumItem); } return(enumList); }
/// <summary> /// 将当前枚举类型转换为IEnumerable<EnumItem>-静态的方法调用 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="enumItem"></param> /// <returns></returns> public static IEnumerable <EnumItem> AsEnumerable <T>(EnumItem enumItem) { bool flag = true; Type enumType = typeof(T); FieldInfo[] fieldInfos = enumType.GetFields(); foreach (FieldInfo fieldInfo in fieldInfos) { if (enumItem != null && flag) { flag = false; yield return(enumItem); } EnumItem item = new EnumItem(); // 过滤掉一个不是枚举值的,记录的是枚举的源类型 if (fieldInfo.FieldType.IsEnum == false) { continue; } // 通过字段的名字得到枚举的值 item.EnumValue = ((int)enumType.InvokeMember(fieldInfo.Name, BindingFlags.GetField, null, null, null)).ToString(); item.EnumKey = fieldInfo.Name; object[] attrs = fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), true); if (attrs != null && attrs.Length > 0) { EnumDescriptionAttribute desc = attrs[0] as EnumDescriptionAttribute; if (desc != null) { item.EnumDescript = desc.Description; } } yield return(item); } }
/// <summary> /// 获取枚举描述 /// </summary> /// <param name="type">枚举值</param> /// <returns>枚举描述</returns> public static string GetRemark <T>(this T type) where T : struct { if (type is Enum) { var t = type as Enum; return(EnumDescriptionAttribute.GetDescription(t)); } return(string.Empty); }
private void BindEnum(Type t) { if (!t.IsEnum) { throw new InvalidOperationException("A DataSource of type 'Type' must be an Enum."); } foreach (KeyValuePair <string, object> pair in EnumDescriptionAttribute.GetEnumData(t)) { AddItem(pair.Key, pair.Value.ToString()); } }
/// <summary> /// Gets an enum value from a provided description. /// </summary> /// <typeparam name="T">The enum type being examined.</typeparam> /// <param name="description">The text description we're trying to find an enum for.</param> /// <returns>Returns the enum matching the description, or the default enum value.</returns> public static T GetValueFromDescription <T>(string description) where T : struct, Enum { var typeInfo = typeof(T).GetTypeInfo(); foreach (var fieldInfo in typeInfo.DeclaredFields) { EnumDescriptionAttribute fieldAttribute = fieldInfo.GetCustomAttribute <EnumDescriptionAttribute>(); if (fieldAttribute?.Description == description || (fieldAttribute == null && fieldInfo.Name == description)) { return((T)fieldInfo.GetValue(null)); } } return(default);
private static string GetDiscription(Enum enumType) { FieldInfo fieldInfo = enumType.GetType().GetField(enumType.ToString()); object[] attrs = fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), true); if (attrs != null && attrs.Length > 0) { EnumDescriptionAttribute desc = attrs[0] as EnumDescriptionAttribute; if (desc != null) { return(desc.Description); } } return(enumType.ToString()); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (DisableAutoConmplete) { writer.AddAttribute(HtmlTextWriterAttribute.AutoComplete, "off"); } string supportsVCard = Context.Request.Browser["supportsVCard"]; if (AutoCompleteType != AutoCompleteType.None && supportsVCard == "true") { writer.AddAttribute(HtmlTextWriterAttribute.VCardName, EnumDescriptionAttribute.ToString(AutoCompleteType)); } }
private object GetHandleType() { Dictionary <string, object> dictionary = new Dictionary <string, object>(); Type t = typeof(HandleTypeEnum); Array arrays = Enum.GetValues(t); for (int i = 0; i < arrays.LongLength; i++) { HandleTypeEnum status = (HandleTypeEnum)arrays.GetValue(i); FieldInfo fieldInfo = status.GetType().GetField(status.ToString()); object[] attribArray = fieldInfo.GetCustomAttributes(false); EnumDescriptionAttribute attrib = (EnumDescriptionAttribute)attribArray[0]; dictionary.Add(status.GetHashCode().ToString(), attrib.Description); } return(dictionary); }
public List <PayRequest> GetPageData(SearchModel <PayRequest> search, out int count) { GetPageListParameter <PayRequest, string> parameter = new GetPageListParameter <PayRequest, string>(); parameter.isAsc = true; parameter.orderByLambda = t => t.DormNo; parameter.pageIndex = search.PageIndex; parameter.pageSize = search.PageSize; parameter.whereLambda = t => !string.IsNullOrEmpty(t.PID); //查询数据 DBBaseService baseService = new DBBaseService(FlatContext.Instance); List <PayRequest> list = baseService.GetSimplePagedData <PayRequest, string>(parameter, out count); foreach (var request in list) { request.StatusStr = EnumDescriptionAttribute.GetDescription((PayRequestStatus)request.Status); request.RealPayMoney = request.Payment.Sum(r => r.PayMoney); } return(list); }
/// <summary> /// Gets an enum value from a provided description. /// </summary> /// <typeparam name="T">The enum type being examined.</typeparam> /// <param name="description">The text description we're trying to find an enum for.</param> /// <returns>Returns the enum matching the description, or the default enum value.</returns> public static T GetValueFromDescription <T>(string description) { var typeInfo = typeof(T).GetTypeInfo(); if (!typeInfo.IsEnum) { throw new InvalidOperationException(); } foreach (var fieldInfo in typeInfo.DeclaredFields) { EnumDescriptionAttribute fieldAttribute = fieldInfo.GetCustomAttribute <EnumDescriptionAttribute>(); if (fieldAttribute?.Description == description || (fieldAttribute == null && fieldInfo.Name == description)) { return((T)fieldInfo.GetValue(null)); } } return(default(T)); }
public static string ToReadableString(this Enum @enum) { FieldInfo fi = @enum.GetType().GetField(@enum.ToString()); EnumDescriptionAttribute attribute = null; try { attribute = fi.GetCustomAttribute <EnumDescriptionAttribute>(); } catch (ArgumentNullException) { return(string.Empty); } if (attribute != null) { return(attribute.Name); } else { return(@enum.ToString().AsSplitPascalCasedString()); } }
public List <Dorm> GetPageData(SearchModel <Dorm> search, out int count) { GetPageListParameter <Dorm, string> parameter = new GetPageListParameter <Dorm, string>(); parameter.isAsc = true; parameter.orderByLambda = t => t.DormNo; parameter.pageIndex = search.PageIndex; parameter.pageSize = search.PageSize; parameter.whereLambda = t => t.Status > -1; //查询数据 DBBaseService baseService = new DBBaseService(FlatContext.Instance); List <Dorm> list = baseService.GetSimplePagedData <Dorm, string>(parameter, out count); foreach (var dorm in list) { dorm.SizeStr = EnumDescriptionAttribute.GetDescription((DormSize)dorm.DormSize); dorm.StatusStr = EnumDescriptionAttribute.GetDescription((DormStatus)dorm.Status); dorm.TypeStr = EnumDescriptionAttribute.GetDescription((DormType)dorm.DormType); dorm.DormJsonStr = JsonConvert.SerializeObject(dorm); } return(list); }
private LanguageModel() { //构造可用的语言列表 FieldInfo[] fieldArray = typeof(LanguageEnum).GetFields(); foreach (var f in fieldArray) { var attrObj = f.GetCustomAttributes(typeof(EnumDescriptionAttribute), false).FirstOrDefault(); if (attrObj == null) { continue; } EnumDescriptionAttribute attr = attrObj as EnumDescriptionAttribute; LanguageInfo info = new LanguageInfo(attr.LanguageName.Equals("English"), attr.LanguageFlag, attr.LanguageName, (LanguageEnum)f.GetValue(typeof(LanguageEnum))); languageInfoList.Add(info); } //先默认一个系统语言 curLanguage = languageInfoList.FirstOrDefault(x => x.IsDefault == true); //读取软件语言,如果没有语言选项则默认当前系统语言,如果系统语言不支持则默认英文 string curLanguageFlag = Properties.Settings.Default.Language; if (!string.IsNullOrEmpty(curLanguageFlag)) { //如果该语言与语言表有匹配则使用匹配语言作为软件语言,否则默认系统语言 var selectLan = this.languageInfoList.FirstOrDefault(lan => lan.LanguageFlag.Equals(curLanguageFlag)); SetCurLanguage(selectLan ?? languageInfoList.FirstOrDefault(x => x.IsDefault == true)); } else { //没有保存的语言则根据系统语言选择 var curSysLanguage = languageInfoList.FirstOrDefault(x => x.LanguageFlag.Equals(Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName)); SetCurLanguage(curSysLanguage ?? languageInfoList.FirstOrDefault(x => x.IsDefault == true)); } }
/// <summary> /// Returns the declined message in case of a cancellation declined. /// </summary> /// <param name="response">Cancellation response.</param> /// <returns>Reason of decline.</returns> private string GetDeclinedMessage(AcceptorCancellationResponse response) { // Verifies if response is null. In this case, there's no declined message. if (response == null) { return(string.Empty); } // Gets the reason as a integer: int reasonCode = Int32.Parse(response.Data.CancellationResponse.TransactionResponse.AuthorisationResult.ResponseToAuthorisation.ResponseReason); // Verifies if the integer read from response XML exists in our response code enumerator: if (Enum.IsDefined(typeof(ResponseReasonCode), reasonCode) == true) { // Returns the corresponding declined message to the response code received: return(EnumDescriptionAttribute.GetDescription((ResponseReasonCode)reasonCode)); } else { // If the response is unknown, then shows it's integer code: return(string.Format("[Erro: {0}]", reasonCode)); } }
public static string ToDescription(this StateItemType enumType) { Type type = typeof(StateItemType); try { FieldInfo info = type.GetField(enumType.ToString()); if (info == null) { return("Unkown"); } EnumDescriptionAttribute descAttribute = info.GetCustomAttributes(typeof(EnumDescriptionAttribute), true)[0] as EnumDescriptionAttribute; if (descAttribute != null) { return(descAttribute.Description); } } catch (Exception e) { Debug.LogWarning(e.Message); } return(type.ToString()); }
public void GetEnumData() { Dictionary <string, object> dictionary = EnumDescriptionAttribute.GetEnumData(typeof(Pet)); Assert.AreEqual(6, dictionary.Count); Assert.IsNotNull(dictionary["My Dog"]); Assert.AreEqual(0, dictionary["My Dog"]); Assert.IsNotNull(dictionary["My Fish"]); Assert.AreEqual(1, dictionary["My Fish"]); Assert.IsNotNull(dictionary["Cat Fish"]); Assert.AreEqual(2, dictionary["Cat Fish"]); Assert.IsNotNull(dictionary["ResourceDog From Embedded Resource"]); Assert.AreEqual(3, dictionary["ResourceDog From Embedded Resource"]); Assert.IsNotNull(dictionary["Resource Fish Default"]); Assert.AreEqual(4, dictionary["Resource Fish Default"]); Assert.IsNotNull(dictionary["Resource Cat Fish"]); Assert.AreEqual(5, dictionary["Resource Cat Fish"]); }
public override string ToString() { StringBuilder sb = new StringBuilder(); if (dataPage.CurrentPageIndex <= 0) { dataPage.CurrentPageIndex = 1; } if (dataPage.RowCount < 0) { dataPage.RowCount = 0; } int halfSize = Convert.ToInt32(Math.Floor(linkSize / 2.0)); if (linkSize % 2 == 0) { halfSize--; } string html = string.Empty; //生成分页的html if (lstyle == LinkStyle.Custom) { sb.Append("<div id='htmlPager' class=\"" + (linkCss ?? EnumDescriptionAttribute.GetDescription(lstyle)) + "\">\n"); } else { sb.Append("<div id='htmlPager' class=\"" + EnumDescriptionAttribute.GetDescription(lstyle) + "\">\n"); } if (dataPage.PageCount == 0) { if (bstyle == ButtonStyle.Button) { sb.Append("<input title=\"上一页\" type=\"button\" value=\"" + prevTitle + "\" disabled=\"disabled\" />\n"); sb.Append("<span class=\"current\">1</span>\n"); sb.Append("<input title=\"下一页\" type=\"button\" value=\"" + nextTitle + "\" disabled=\"disabled\" />\n"); } else { sb.Append("<span class=\"disabled\" title=\"上一页\">" + prevTitle + "</span>\n"); sb.Append("<span class=\"current\">1</span>\n"); sb.Append("<span class=\"disabled\" title=\"下一页\">" + nextTitle + "</span>\n"); } } else { if (bstyle == ButtonStyle.Button) { if (!dataPage.IsFirstPage) { sb.Append("<input title=\"上一页\" type=\"button\" onclick=\"" + GetButtonLink(dataPage.CurrentPageIndex - 1) + "\" value=\"" + prevTitle + "\" />\n"); } else { sb.Append("<input title=\"上一页\" type=\"button\" value=\"" + prevTitle + "\" disabled=\"disabled\" />\n"); } } else { if (!dataPage.IsFirstPage) { sb.Append("<a href=\"" + GetHtmlLink(dataPage.CurrentPageIndex - 1) + "\" title=\"上一页\">" + prevTitle + "</a>\n"); } else { sb.Append("<span class=\"disabled\" title=\"上一页\">" + prevTitle + "</span>\n"); } } int startPage = dataPage.CurrentPageIndex; if (startPage <= halfSize || dataPage.PageCount <= linkSize) { startPage = halfSize + 1; } else if (startPage + halfSize >= dataPage.PageCount) { startPage = dataPage.PageCount - halfSize; if (linkSize % 2 == 0) { startPage--; } } int beginIndex = startPage - halfSize; int endIndex = startPage + halfSize; if (linkSize % 2 == 0) { endIndex++; } if (beginIndex - 1 > 0) { if (beginIndex - 1 == 1) { sb.Append("<a href=\"" + GetHtmlLink(1) + "\" title=\"第1页\">[1]</a>\n"); } else { sb.Append("<a href=\"" + GetHtmlLink(1) + "\" title=\"第1页\">[1]</a></span>... \n"); } } for (int index = beginIndex; index <= endIndex; index++) { if (index > dataPage.PageCount) { break; } if (index == dataPage.CurrentPageIndex) { sb.Append("<span class=\"current\">"); sb.Append(index); sb.Append("</span>\n"); } else { sb.Append("<a href=\"" + GetHtmlLink(index) + "\" title=\"第" + index + "页\">[" + index + "]</a>\n"); } } if (endIndex + 1 <= dataPage.PageCount) { if (endIndex + 1 == dataPage.PageCount) { sb.Append("<a href=\"" + GetHtmlLink(endIndex + 1) + "\" title=\"第" + (endIndex + 1) + "页\">[" + (endIndex + 1) + "]</a>\n"); } else { sb.Append("... <a href=\"" + GetHtmlLink(dataPage.PageCount) + "\" title=\"第" + dataPage.PageCount + "页\">[" + dataPage.PageCount + "]</a>\n"); } } if (bstyle == ButtonStyle.Button) { if (!dataPage.IsLastPage) { sb.Append("<input title=\"下一页\" type=\"button\" onclick=\"" + GetButtonLink(dataPage.CurrentPageIndex + 1) + "\" value=\"" + nextTitle + "\" />\n"); } else { sb.Append("<input title=\"下一页\" type=\"button\" value=\"" + nextTitle + "\" disabled=\"disabled\" />\n"); } } else { if (!dataPage.IsLastPage) { sb.Append("<a href=\"" + GetHtmlLink(dataPage.CurrentPageIndex + 1) + "\" title=\"下一页\">" + nextTitle + "</a>\n"); } else { sb.Append("<span class=\"disabled\" title=\"下一页\">" + nextTitle + "</span>\n"); } } } if (showGoto) { sb.Append(" / 第 <select id=\"pageSelect\" onchange=\"" + GetHtmlLink("this.value") + "\">\n"); if (dataPage.PageCount == 0) { sb.Append("<option value=\"1\" selected=\"selected\">1</option>\n"); } else { for (int index = 1; index <= dataPage.PageCount; index++) { if (index == dataPage.CurrentPageIndex) { sb.Append("<option value=\"" + index + "\" selected=\"selected\">"); sb.Append(index); sb.Append("</option>\n"); } else { sb.Append("<option value=\"" + index + "\">"); sb.Append(index); sb.Append("</option>\n"); } } } sb.Append("</select> 页 \n"); } if (showRecord) { sb.Append(" 共<span class=\"red\">" + dataPage.RowCount + "</span>条 / 每页<span class=\"red\">" + dataPage.PageSize + "</span>条\n"); } sb.Append("<input type=\"hidden\" id=\"currentPage\" value=\"" + dataPage.CurrentPageIndex + "\"/>\n"); sb.Append("</div>\n"); html = sb.ToString(); if (!showBracket) { Regex reg = new Regex(@"\[([\d]+)\]"); html = reg.Replace(html, "$1"); } return(html); }
public void FromDescription(Pet pet, string expected) { string actual = EnumDescriptionAttribute.ToString(pet); Assert.AreEqual(expected, actual); }
public static string GetName(this Enum enumVal) { EnumDescriptionAttribute attr = GetAttributeOfType <EnumDescriptionAttribute>(enumVal); return(attr?.Name ?? string.Empty); }
private void Setup() { SizeChanged += OnSizeChanged; StackLayout layout = new StackLayout { Padding = new Thickness(20, 28), Spacing = 0 //VerticalOptions = LayoutOptions.Center, }; layout.Children.Add( new StackLayout { Orientation = StackOrientation.Horizontal, Children = { // Section new Label { Text = "Section " + question.section.Label + ": " + question.section.Title, FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.StartAndExpand }, // Question Number new Label { Text = "Question " + question.numberString, HorizontalOptions = LayoutOptions.EndAndExpand, XAlign = TextAlignment.End, FontAttributes = FontAttributes.Bold } } } ); // Part if (question.SectionPartId != null) { layout.Children.Add( new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "Part " + question.part.Label + ": " + question.part.Description } } }); } layout.Children.Add(LayoutHelper.GetVerticalSpacing(20)); layout.Children.Add(LayoutHelper.GetHorizontalLine()); // Question text layout.Children.Add( new StackLayout { BackgroundColor = Color.FromHex("#ffd758"), Padding = new Thickness(10, 20, 10, 20), Children = { new Label { Text = (textOverride == null) ? question.Text.Trim() : textOverride, FontAttributes = FontAttributes.Italic } } }); layout.Children.Add(LayoutHelper.GetHorizontalLine()); //Add Edit Comment Button Button commentButton = new Button(); commentButton.Text = "Add/Edit Comment For Question"; commentButton.FontAttributes = FontAttributes.Italic; commentButton.Clicked += openCommentPage; commentButton.HorizontalOptions = LayoutOptions.End; layout.Children.Add(commentButton); layout.Children.Add(LayoutHelper.GetVerticalSpacing(5)); //Answer score = inspection.GetScoreForQuestion(question); if (score != null) { HasScore = true; var answer = EnumDescriptionAttribute.GetDescriptionFromEnumValue(score.answer); } else { HasScore = false; } // Answers - Radio Group var answers = Enum.GetValues(typeof(Answer)).Cast <Answer>().ToList(); var answerRadioGroup = new BindableRadioGroup { ItemsSource = answers.Select(x => EnumDescriptionAttribute.GetDescriptionFromEnumValue(x)), SelectedIndex = HasScore == true?answers.FindIndex(x => x.Equals(score.answer)) : -1 }; answerRadioGroup.Spacing = 12; answerRadioGroup.CheckedChanged += answerRadioGroup_CheckedChanged; answerRadioGroup.ItemUnchecked += answerRadioGroup_Unchecked; layout.Children.Add(new StackLayout { Children = { answerRadioGroup } }); layout.Children.Add(LayoutHelper.GetVerticalSpacing(25)); // References label layout.Children.Add(new Label { Text = "References:", FontAttributes = FontAttributes.Bold }); layout.Children.Add(LayoutHelper.GetVerticalSpacing(5)); layout.Children.Add(LayoutHelper.GetHorizontalLine()); //References buttons List <Reference> references = question.References; if (extraReferences != null) { //Creates a copy of the list so we aren't adding to the original. references = references.ToList(); references.AddRange(extraReferences); } foreach (Reference reference in references) { var referenceButton = new ReferenceButton(reference) { folderName = inspection.ChecklistId, FontAttributes = FontAttributes.Italic, HorizontalOptions = LayoutOptions.StartAndExpand }; layout.Children.Add( new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness(24, 0), HeightRequest = 30, Children = { new Label { TextColor = Color.FromHex("#2b90ff"), FontSize = 40, XAlign = TextAlignment.Center, Text = "\u2022" }, LayoutHelper.GetHorizontalSpacing(8), referenceButton } }); } layout.Children.Add(LayoutHelper.GetVerticalSpacing(25)); //Remarks label layout.Children.Add(new Label { Text = "Remarks:", FontAttributes = FontAttributes.Bold }); //Remarks box remarksBox = new Editor(); remark = inspection.GetRemarkForQuestion(question); if (App.IsPortrait(this)) { remarksBox.HeightRequest = 300; } else { remarksBox.HeightRequest = 100; } if (remark == null) { remarksBox.Text = string.Empty; question.OldRemarks = string.Empty; } else { remarksBox.Text = remark.remark; question.OldRemarks = remark.remark; } remarksBox.TextChanged += SaveRemarksText; layout.Children.Add(remarksBox); ScrollView scroll = new ScrollView(); scroll.Content = layout; Device.BeginInvokeOnMainThread(() => { Content = scroll; }); }