Reputation: 15245
In Windows 8.1, I can do this
<Grid Margin="8"
VerticalAlignment="Bottom"
Tapped="Grid_OnTapped"
Tag="{Binding}"></Grid>
then inside event Grid_OnTapped, I can use the Tag property of Grid to know which item is tapped.
But when change to x:Bind, it's no longer work. Exception throwed: "Object reference is not set to an instance of an object"
Further test, this code will display the name of the class
<TextBlock Text="{x:Bind}/>
But that the only thing work
Please help. Thanks
Upvotes: 0
Views: 976
Reputation: 9713
{x:Bind}
is for binding to properties in the code-behind of the view. It has a performance advantage over {Binding}
because normal binding uses reflection to find properties, whereas x:Bind
does not. x:Bind
will bind to strongly typed properties in the code-behind.
Generally, you would use x:Bind
to gain performance in XAML
.
In your case, it would be a better idea to bind the to DataContext
instead, in your case, is just {Binding}
. Which is what you have already done previously.
Perhaps you have misunderstood the usage of x:Bind
? Here's an article explaining how it should be used.
Upvotes: 1