SIGN UP MEMBER LOGIN:    
Blog

Data binding with textbox in silverlight

Posted by Alok Pandey Blogs | Silverlight using VB.NET Sep 14, 2011
Here, We will look simple data binding with TextBox in Silverlight.

We take a Silverlight application and write the following XAML code in editor

  <Grid x:Name="LayoutRoot" Background="White" ShowGridLines="True">
    <TextBox Height="36" HorizontalAlignment="Left" FontSize="17" Text="{Binding Path=fname}" Margin="164,14,0,0" Name="textBox1" VerticalAlignment="Top" Width="182" />
    <TextBlock Height="23" HorizontalAlignment="Left" Margin="81,16,0,0" FontSize="18" Name="textBlock1" Text="Name :" VerticalAlignment="Top" />     </Grid>

And following code on MainPage.xaml.vb

Partial Public Class MainPage
    Inherits UserControl
    Public Sub New()
        InitializeComponent()
        Dim obj As New abc()
        obj.fname = "Alok Kumar"
        textBox1.DataContext = obj
    End Sub
    Public Class abc
        Public Sub New()
        End Sub
        Public Property fname() As String
            Get
                Return m_fname
            End Get
        Set(value As String)
            m_fname = Value
            End Set
        End Property
    Private m_fname As String
        End
Class

End
Class

When, We run our application the output will be look like below figure

 data binding with textboxdata binding with textbox

           

 

 

share this blog :
post comment