如何将ContentView添加到Click事件?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何将ContentView添加到Click事件?相关的知识,希望对你有一定的参考价值。

我的任务是创建一个程序,在主屏幕上显示两个按钮,我的名字和当前时间/日期。目标是在按下按钮之后显示一个通道,该按钮将使用整个屏幕。到目前为止,我已经创建了带有标签和按钮的主页面。但是,我很遗憾如何显示相对于点击按钮的段落。我使用经验适合的文本方式来充分利用屏幕。我已经创建了一个FontCalc.Cs页面,并在我拥有所有代码的主页中添加了onContentViewSizeChanged方法。我不知道接下来该怎么做。到目前为止,这是我在点击处理程序事件中的内容:

        passage1Button.Clicked += (sender, args) =>
        {
            passage.Text = "So they began working together, each squadron leader commanding indivual pilots, " +
                           "Ender comanding the squadron leaders. They learned manyw ays of working together, " +
                           "as the simulator forced them to try different situations. Sometimes the simulator " +
                           "gave them a larger fleet to work with; Ender set them up then in three or four " +
                           "toons that consisted of three or four squadrons each. Sometimes the simulator gave " +
                           "them a single starship with its twelve fighters, and he chose three sqaudron leaders. ";

            ContentView contentView = new ContentView
            {
                Content = passage
            };
            contentView.SizeChanged += onContentViewSizeChanged;

它不是在按钮消失的情况下显示通道,而是仅冻结android模拟器和UWP本地机器。

答案

您可以在按钮单击时显示模态

        passage1Button.Clicked += (sender, args) =>
         {
            var contentpage = new ShowTextPage("Passage text here, goes to page constructor where label is set to passed text");

            var page = new NavigationPage(contentpage);

            Navigation.PushModalAsync(page);
         }

在ShowTextPage上,将HasNavigationBar设置为false

以上是关于如何将ContentView添加到Click事件?的主要内容,如果未能解决你的问题,请参考以下文章

如何在运行时使用 VBA 将按钮添加到 MS Access 表单并将代码添加到 _Click() 事件

如何将 UIViews 添加到我的 contentView (AwakeFromNib)

如何检索使用 click() 添加的 onclick 事件 [重复]

将click事件添加到ios NSString中的某些文本

如何将点击事件添加到插入的元素

将 ng-click 事件添加到 angular-ui 手风琴