当前位置: 首页>>代码示例>>C#>>正文


C# StackPanel.FindName方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Controls.StackPanel.FindName方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.FindName方法的具体用法?C# StackPanel.FindName怎么用?C# StackPanel.FindName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Controls.StackPanel的用法示例。


在下文中一共展示了StackPanel.FindName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadQuranPane

        public void loadQuranPane(int chapterNo, int verseNo)
        {
            codeBehindReadingSP = readingSP;

            XmlReader quranTextReader = XmlReader.Create("quran/sura"+chapterNo+".xml", settings);

            int tcount = 0;

            if (showTranslation == true && fileFound)
            {
                myTranslation = linqQuery(chapterNo);
            }
            
            while (quranTextReader.Read())
            {
                if ((quranTextReader.NodeType == XmlNodeType.Element) && (quranTextReader.Name == "sura"))
                {
                    TextBlock sura = new TextBlock();
                    sura.Name = "chapterNamesRightPane" + quranTextReader.GetAttribute("index");
                    sura.Foreground = new SolidColorBrush(Colors.AliceBlue);
                    sura.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
                    sura.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
                    sura.FontSize = 45;
                    sura.FontWeight = Windows.UI.Text.FontWeights.Bold;
                    sura.Margin = new Thickness(5, 10, 5, 10);
                    sura.FlowDirection = Windows.UI.Xaml.FlowDirection.RightToLeft;
                    sura.FontFamily = new FontFamily("/fonts/me_quran.ttf#me_quran");
                    
                    codeBehindReadingSP.Children.Add(sura);

                    if (quranTextReader.HasAttributes)
                        sura.Text = " سورة " + quranTextReader.GetAttribute("name");
                }

                if ((quranTextReader.NodeType == XmlNodeType.Element) && (quranTextReader.Name == "aya"))
                {
                    if (quranTextReader.HasAttributes)
                    {

                        tcount = Convert.ToInt16(quranTextReader.GetAttribute("index"));
                        TextBlock aya = new TextBlock();
                        aya.Name = "ayaRightPane" + tcount;
                        aya.Foreground = new SolidColorBrush(Colors.White);
                        aya.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                        aya.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch;
                        aya.TextWrapping = TextWrapping.Wrap;
                        aya.FontSize = 25;
                        aya.FontWeight = Windows.UI.Text.FontWeights.Bold;
                        aya.Margin = new Thickness(5, 10, 5, 10);
                        aya.FlowDirection = Windows.UI.Xaml.FlowDirection.RightToLeft;
                        aya.Tag = chapterNo + ":" + quranTextReader.GetAttribute("index").ToString();
                        aya.FontFamily = new FontFamily("/fonts/me_quran.ttf#me_quran");

                        aya.Tapped += rightPaneItem_Tapped;
                        codeBehindReadingSP.Children.Add(aya);

                        aya.Text = quranTextReader.GetAttribute("text");


                        //translation
                        if (showTranslation == true && fileFound)
                        {
                            try
                            {
                                TextBlock ayaTranslation = new TextBlock();
                                ayaTranslation.Name = "ayaTranslationRightPane" + myTranslation.ElementAt(tcount-1).ayaID;
                                ayaTranslation.Foreground = new SolidColorBrush(Colors.Black);
                                ayaTranslation.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                                ayaTranslation.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch;
                                ayaTranslation.TextWrapping = TextWrapping.Wrap;
                                ayaTranslation.TextAlignment = TextAlignment.Right;
                                ayaTranslation.FontSize = 20;
                                ayaTranslation.FontWeight = Windows.UI.Text.FontWeights.Bold;
                                ayaTranslation.Margin = new Thickness(5, 10, 5, 10);

                                codeBehindReadingSP.Children.Add(ayaTranslation);

                                ayaTranslation.Text = myTranslation.ElementAt(tcount-1).text;
                            }
                            catch (Exception e)
                            {
                                tbHeading.Text = e.Message.ToString();
                                //MessageDialog msg = new MessageDialog(e.Message.ToString(), "Muslim Suite Pro");
                                //msg.ShowAsync();   
                            }
                        }

                    }
                }
            }

            if (chapterNo == bookmarkedChapter)
            {
                TextBlock previousBookmark = new TextBlock();
                previousBookmark = (TextBlock)codeBehindReadingSP.FindName(("ayaRightPane" + bookmarkedVerse));
                previousBookmark.Foreground = new SolidColorBrush(Colors.Gold);
            }

        }
开发者ID:Chengxuan,项目名称:MuslimSuitePro,代码行数:99,代码来源:Quran.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.StackPanel.FindName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。