當前位置: 首頁>>代碼示例>>C#>>正文


C# TextBox.GetType方法代碼示例

本文整理匯總了C#中Windows.UI.Xaml.Controls.TextBox.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.GetType方法的具體用法?C# TextBox.GetType怎麽用?C# TextBox.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Xaml.Controls.TextBox的用法示例。


在下文中一共展示了TextBox.GetType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SaveDataOfCard

        public async void SaveDataOfCard()
        {
            SaveAndLoad DataSaverLoader = new SaveAndLoad();
            CardObj DataToBeSaved = new CardObj();
            StackPanel Tmp_SP = new StackPanel();
            TextBox Tmp_TX = new TextBox();

            //First time loop through to delete and correct empty entries
            foreach (UIElement IngredientEntry in this.recipePanel.Children)
            {
               
                if (IngredientEntry.GetType() == Tmp_SP.GetType())
                {
                    
                    StackPanel ThisEntry = (StackPanel)IngredientEntry;
                    //this entry could be empty
                    NumberSelector NS = (NumberSelector)ThisEntry.Children[0];
                    UnitSelector US = (UnitSelector)ThisEntry.Children[1];
                    TextBox TX = (TextBox)ThisEntry.Children[2];
                    //non empty entry
                    if (NS.getSelectedValue() != "" && TX.Text.ToString() != "Drag and drop ingredient here")
                    {
                        TextBox FinalEntryBox = new TextBox();
                        FinalEntryBox.Text = NS.getSelectedValue() + " " + US.getSelectedValue() + " " + TX.Text;
                        /******INSERT TAG******/
                        DataToBeSaved.TagsList.Add(TX.Text);
                        /******INSERT TAG******/
                        FinalEntryBox.Width = width;
                        ThisEntry.Children.Clear();
                        StackPanel Card = (StackPanel)ThisEntry.Parent;
                        int index = Card.Children.IndexOf(ThisEntry);
                        Card.Children.Remove(ThisEntry);
                        Card.Children.Insert(index, FinalEntryBox);
                    }
                    //empty entry
                    else
                    {
                        ThisEntry.Children.Clear();
                        StackPanel Card = (StackPanel)ThisEntry.Parent;
                        Card.Children.Remove(ThisEntry);
                    }
                        
                    
                }
                
            }


            //All entries should be textboxes now 
            disableEditing();

            for (int i = 0; i < this.recipePanel.Children.Count; i++)
            {
                TextBox ThisEntry = (TextBox)this.recipePanel.Children[i];
                DataToBeSaved.IngredientList.Add(ThisEntry.Text.ToString());
                if (i == 0) //first entry is title add to tags
                {
                    DataToBeSaved.TagsList.Add(ThisEntry.Text.ToString());
                    DataToBeSaved.CardTitle = ThisEntry.Text.ToString();
                }
            }



            for (int i = 0; i < this.reversePanel.Children.Count; i++)
            {
                TextBox ThisEntry;
                if (this.reversePanel.Children[i].GetType() == Tmp_TX.GetType())
                {
                    ThisEntry = (TextBox)this.reversePanel.Children[i];
                    DataToBeSaved.InstructionList.Add(ThisEntry.Text.ToString());

                    if (i == 0) //first entry is title add to tags
                        DataToBeSaved.TagsList.Add(ThisEntry.Text.ToString());
                }

             
            }



            LocalAppData AllCardsCollection = await DataSaverLoader.LoadData();
            int ReplaceIndex = -1;
            for (int i = 0; i < AllCardsCollection.AllCardData.Count; i++)
            {
                if (DataToBeSaved.CardTitle == AllCardsCollection.AllCardData[i].CardTitle)
                {
                    ReplaceIndex = i;
                    break;
                }
            }

            if (ReplaceIndex != -1) //Replace
            {
                AllCardsCollection.AllCardData[ReplaceIndex] = DataToBeSaved;
            }
            else
            {
                AllCardsCollection.AddCard(DataToBeSaved);
            }
//.........這裏部分代碼省略.........
開發者ID:wangfowen,項目名稱:Recipe_Box,代碼行數:101,代碼來源:recipeCard.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.TextBox.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。