0

ユニバーサル Windows 10 アプリで新しいコンパイル済みバインディングをテストするための次のコードがあります。

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

2 つのバインディング タイプを並べてテストしています...標準の {Binding...} タイプは正常に動作していますが、新しい x:Bind は奇妙に動作していません...

おそらく、新しいバインディングがどのように機能するかを誤解していますか? しかし、x:Bind が CodeBehind にバインドされていること、必要なのはバインド先のパブリック プロパティだけであることがわかりました。

VS2015 RC と Win 10 ビルド 10130 を使用しています。

4

1 に答える 1

0

x:bindVS2015RC の vb.net には実装されていないことが判明しました。MS は、これが完全な RTM に実装されることを確認しています。

于 2015-07-08T10:08:27.290 に答える