[英]Setting the Text Property of a Textbox (Windows Phone 8 App)
Basically I want to set a textbox value equal to the CustomerName from a card which is created for Wallet. 基本上,我想从为电子钱包创建的卡中设置一个文本框值,该值等于CustomerName。 What do I need to set the text property of textbox equal to, in order to achieve this.
为了实现此目的,我需要将文本框的text属性设置为等于什么。 Is this possible?
这可能吗? Thanks
谢谢
Product.xaml (Where textbox is) Product.xaml(此处是文本框)
The Code 编码
<TextBoxGrid.Row="1"Grid.Column="0"Name="TodoInput2"Text="{}"Visibility="Collapsed"/>
Product.xaml.cs
(Where the card for Wallet is created, I want to set my textbox equal to the value of Pi.CustomerName=member. Name
) Product.xaml.cs
(在创建电子钱包卡的地方,我要将文本框设置为等于Pi.CustomerName=member. Name
的值)
The Code 编码
PaymentInstrument PI;
PI = new PaymentInstrument("Account")
Pi.CustomerName = member. Name;
you should set PI as the datacontext for the page or for the textbox and then you can bind to it by using 您应该将PI设置为页面或文本框的数据上下文,然后可以使用绑定到它
<TextBoxGrid.Row="1"Grid.Column="0"Name="TodoInput2"Text="{Binding CustomerName}"Visibility="Collapsed"/>
for setting the datacontext on the textbox or in any other element you can give the element a name and in code behind set the datacontext for example 在文本框或任何其他元素中设置数据上下文时,可以给元素命名,并在后面的代码中设置数据上下文
<TextBoxGrid x:Name=TxtBox>
<TextBoxGrid.Row="1"Grid.Column="0"Name="TodoInput2"Text="{Binding CustomerName}"Visibility="Collapsed"/>
</TextBoxGrid>
in codebehind 在代码背后
TxtBox.DataContext=PI;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.