/// <summary> /// Builds the content to be displayed on the block. /// </summary> /// <returns>A string containing the XAML content to be displayed.</returns> private string BuildContent() { string content = @" <StackLayout> ##HEADER## ##FIELDS## <Rock:Validator x:Name=""vForm""> ##VALIDATORS## </Rock:Validator> <Rock:NotificationBox x:Name=""nbError"" NotificationType=""Error"" /> <Button StyleClass=""btn,btn-primary"" Text=""Save"" Margin=""24 0 0 0"" Command=""{Binding Callback}""> <Button.CommandParameter> <Rock:CallbackParameters Name=""Save"" Validator=""{x:Reference vForm}"" Notification=""{x:Reference nbError}""> ##PARAMETERS## </Rock:CallbackParameters> </Button.CommandParameter> </Button> <Button StyleClass=""btn,btn-link"" Text=""Cancel"" ##CANCEL## /> </StackLayout>"; var groupGuid = RequestContext.GetPageParameter(PageParameterKeys.GroupGuid).AsGuid(); var parameters = new Dictionary <string, string>(); string fieldsContent; using (var rockContext = new RockContext()) { var group = new GroupService(rockContext).Get(groupGuid); if (group == null) { return("<Rock:NotificationBox HeaderText=\"Error\" Text=\"We couldn't find that group.\" NotificationType=\"Error\" />"); } else if (!group.IsAuthorized(Authorization.EDIT, RequestContext.CurrentPerson)) { return("<Rock:NotificationBox HeaderText=\"Error\" Text=\"You are not authorized to edit this group.\" NotificationType=\"Error\" />"); } group.LoadAttributes(rockContext); var attributes = GetEditableAttributes(group); fieldsContent = BuildCommonFields(group, parameters); fieldsContent += MobileHelper.GetEditAttributesXaml(group, attributes, parameters); } var validatorsContent = parameters.Keys.Select(a => $"<x:Reference>{a}</x:Reference>"); var parametersContent = parameters.Select(a => $"<Rock:Parameter Name=\"{a.Key}\" Value=\"{{Binding {a.Value}, Source={{x:Reference {a.Key}}}}}\" />"); if (GroupDetailPage.HasValue) { content = content.Replace("##CANCEL##", $"Command=\"{{Binding ReplacePage}}\" CommandParameter=\"{GroupDetailPage}?{GroupView.PageParameterKeys.GroupGuid}={groupGuid}\""); } else { content = content.Replace("##CANCEL##", "Command=\"{Binding PopPage}\""); } if (ShowHeader) { content = content.Replace("##HEADER##", @"<Label StyleClass=""h2"" Text=""Group Details"" /> <Rock:Divider />"); } else { content = content.Replace("##HEADER##", string.Empty); } return(content.Replace("##FIELDS##", fieldsContent) .Replace("##VALIDATORS##", string.Join(string.Empty, validatorsContent)) .Replace("##PARAMETERS##", string.Join(string.Empty, parametersContent))); }