I have a template that receives a string
as its data type:
<DataTemplate x:DataType="System:String">
<TextBlock Text="{x:Bind}" />
</DataTemplate>
But this binding technique gives me a build error. How can I use {x:Bind}
without a path value? I want to bind the string, not a property in the string.
x-bind allows you to set HTML attributes on elements based on the result of JavaScript expressions. For example, here's a component where we will use x-bind to set the placeholder value of an input. <div x-data="{ placeholder: 'Type here...' }"> <input type="text" x-bind:placeholder="placeholder">
You typically use a DataTemplate to specify the visual representation of your data.
You actually can do Text="{x:Bind}"
without specifying a path. The Designer will complain but it's safe to ignore it.
I think the problem is the way you define the string type. Note in WinRT XAML it now writes as x:String
.
So this should work -
<DataTemplate x:Key="GroupTemplate" x:DataType="x:String">
<TextBlock Text="{x:Bind}" />
</DataTemplate>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With