我在列表框中有按钮,对于每个按钮,我想要提供不同的名称。以下是我在XAML中设置绑定的方法:
<Button Content="{Binding count}"
x:Name="{Binding buttonName}"
Width="55"
Height="55"
BorderThickness="3"
FontSize="18.667"
Padding="-1,-2,0,0"
Margin="-400,0,0,0"
FontWeight="Bold"
Click="servingButtonClicked" />
buttonName
是一个字符串,作为listBox的itemSource存储在LinkedList<string>
中的对象中。
为什么这个不行?
错误:Object reference not set to an instance of an object.
x:Name不能通过DataBinding来确定-这是对象实例的名称,而不是动态的。