// Constructor
        public GroupRulesView()
        {
            InitializeComponent();

            joinButton = new API.Avarice.Controls.Button();
            joinButton.Content = AppResources.GenericAgreeText;
            joinButton.Click += (sender, e) => {
                if (GroupSource.IsInvitationOnly)
                {
                    var requestView = new GroupJoinRequestView();
                    requestView.Group = GroupSource;
                    requestView.PopupContainer = PopupContainer;

                    PopupContainer.ReplaceContentWith(AppResources.GroupInvitationRequestText, requestView, requestView.Buttons);
                }
                else
                {
                    var statusView = new GroupJoiningStatusView();
                    statusView.Group = GroupSource;
                    statusView.PopupContainer = PopupContainer;

                    PopupContainer.ReplaceContentWith(AppResources.GroupJoiningText, statusView, statusView.Buttons, () =>
                    {
                        statusView.BeginJoinGroup();
                    });
                }

            };

            cancelButton = new API.Avarice.Controls.Button();
            cancelButton.Content = AppResources.GenericCancelText;
            cancelButton.Click += (sender, e) =>
            {
                PopupContainer.Dismiss();
            };

            Buttons = new List<API.Avarice.Controls.Button>();
            Buttons.Add(joinButton);
            Buttons.Add(cancelButton);
        }
        private void JoinGroup()
        {
            if (Group.Rules != null && Group.Rules.Length > 0)
            {
                var rulesView = new GroupRulesView();
                rulesView.GroupSource = Group;
                rulesView.PopupContainer = _popupContainer;

                _popupContainer.ReplaceContentWith(AppResources.GroupRulesText, rulesView, rulesView.Buttons);
            }
            else
            {
                if (Group.IsInvitationOnly)
                {
                    var requestView = new GroupJoinRequestView();
                    requestView.Group = Group;
                    requestView.PopupContainer = _popupContainer;

                    _popupContainer.ReplaceContentWith(AppResources.GroupInvitationRequestText, requestView, requestView.Buttons);
                }
                else
                {
                    var statusView = new GroupJoiningStatusView();
                    statusView.Group = Group;
                    statusView.PopupContainer = _popupContainer;

                    _popupContainer.ReplaceContentWith(AppResources.GroupJoiningText, statusView, statusView.Buttons, () =>
                    {
                        statusView.BeginJoinGroup();
                    });
                }
            }
        }