2016-09-26 66 views
0

我正在使用Visual Studio Express 2015.我現在只使用它3天。這個問題一直存在於我參與的任何項目中。無法將目標標籤與C#代碼中的.Text對齊

我想更改標籤內的文本。我創建了一個新的WPF項目,在表單上放置一個標籤,給標籤一個名稱,並確保它在我的XAML代碼中有一個「x:」。 Intellisense在我開始輸入時找不到「lblTest」,如果我輸入「lblTest.Text」,我會得到:

'標籤'不包含'文本'的定義,也沒有擴展方法'文本'接受第一個參數類型'標籤'可以找到(您是否缺少使用指令或程序集引用?)

下面是我已經導入到我的項目中的命名空間。我可以發佈我的代碼,但在我的示例中,我剛創建了一個空白WPF應用程序,在其上放置了一個標籤,並試圖找到它。我非常感謝你閱讀本文的時間!

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
+0

試試'lblTest.Content',看看你是否可以更新它。 –

回答

0

一些WPF控件的使用從WinForms的

在WPF標籤不同的屬性名稱使用Content代替。

+0

我愛你!我正在尋找的正確功能是lblTest.Content =「Sample」; –

+0

我很樂意提供幫助:D –