2015-06-29 52 views
0

我有以下代碼來測試通用Windows 10應用程序中的新編譯綁定。Windows 10通用應用程序編譯綁定/ x:綁定不工作

XAML:

<Page 
x:Class="xBindTest.MainPage" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:xBindTest" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" 
DataContext="{Binding RelativeSource={RelativeSource Self}}"> 

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> 

     <TextBlock x:Name="Tester" Text="{x:Bind myBindClass.TestText, Mode=OneWay}" ></TextBlock> 
     <TextBlock x:Name="Tester2" Text="{Binding myBindClass.TestText, Mode=OneWay}" ></TextBlock> 
     <Button x:Name="button" Content="Button" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> 

    </StackPanel>    

</Grid> 

代碼背後:

Public Class xBindClass : Implements INotifyPropertyChanged 

    Private _TestText As String 

    Public Property TestText As String 
     Get 
      Return _TestText 
     End Get 
     Set(value As String) 

      If _TestText <> value Then 

       _TestText = value 
       NotifyPropertyChanged("TestText") 

      End If 
     End Set 
    End Property 

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged 

    Private Sub NotifyPropertyChanged(<CallerMemberName> Optional propertyName As String = "") 
     RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) 
    End Sub 

End Class 

''' <summary> 
''' An empty page that can be used on its own or navigated to within a Frame. 
''' </summary> 
Public NotInheritable Class MainPage 
    Inherits Page 


    Public Property myBindClass As xBindClass 

    Public Sub New() 

     ' Add any initialization after the InitializeComponent() call. 

     myBindClass = New xBindClass With {.TestText = "Hello"} 

     ' This call is required by the designer. 
     InitializeComponent() 

    End Sub 

    Private Sub button_Click(sender As Object, e As RoutedEventArgs) Handles button.Click 
     myBindClass.TestText &= " There" 

     Tester.DataContext = myBindClass.TestText 

    End Sub 
End Class 

我測試通過兩側的兩個綁定類型側...標準{結合。 ..}類型工作正常,但新的x:綁定並不奇怪...

也許我誤解了新綁定的工作原理?但是我明白了,綁定到CodeBehind的x:綁定,並且所有需要的都是綁定到的公共屬性,並且您已關閉並正在運行。

我使用VS2015 RC和Win 10的構建10130.

回答

0

原來,x:bind沒有在vb.net實施了VS2015RC.MS已經確認這將在全RTM

實施
相關問題