在Silverlight 4中,我有一个与之绑定的内容控件

AddEditUser.DataContext=SomeUser; 

问题是,当我在字段中输入数据时,我检查了对象,但该对象不包含我在字段中输入的数据。

<ContentControl Name="AddEditUser">
            <Grid Width="392" Height="183">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="77*" />
                    <ColumnDefinition Width="168" />
                    <ColumnDefinition Width="100" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Add/Edit User"/>
                <Button Grid.Row="0" Grid.Column="1"  Width="50" Content="New" Click="Button_Click" />
                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="2"  >
                    <Button Width="50" Content="Save" Click="Button_Click_1" />
                    <Button Width="50" Content="Delete" Click="Button_Click_2" />
                </StackPanel>
                <TextBlock Grid.Row="1" Grid.Column="0" Text="User name:"/>
                <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=Username}" Name="UserName" Width="168"></TextBox>
                <TextBlock Grid.Row="2" Grid.Column="0" Text="Password:"/>
                <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=Password}" Width="168"></TextBox>
                <TextBlock Grid.Row="3" Grid.Column="0" Text="First name:"/>
                <TextBox Grid.Row="3" Grid.Column="1"  Text="{Binding Path=FirstName}" Width="168"></TextBox>
                <TextBlock Grid.Row="4" Grid.Column="0" Text="Last name:"/>
                <TextBox Grid.Row="4" Grid.Column="1"   Text="{Binding Path=LastName}" Width="168"></TextBox>
                <TextBlock Grid.Row="5" Grid.Column="0" Text="Admin:"/>
                <CheckBox Grid.Row="5" Grid.Column="1" Name="AdminCheckbox"  Content="{Binding Path=Admin}" Width="168"/>
                <TextBlock Grid.Row="6" Grid.Column="0" Text="Title:"/>
                <TextBox Grid.Row="6" Grid.Column="1" Text="{Binding Path=Title}" Width="168"></TextBox>
                <TextBlock Grid.Row="7" Grid.Column="0" Text="Email:"/>
                <TextBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=Email}" Width="168"></TextBox>
            </Grid>
        </ContentControl>

===============>>#1 票数:1 已采纳

在文本框中使用TwoWay绑定来获取在字段中输入的数据作为对象。 默认绑定模式是一种方式。

  ask by Paul Rusu translate from so

未解决问题?本站智能推荐:

关注微信公众号