locked
How to Binding database table each row to textbox xmal file using wpf mvvm Entity framework RRS feed

  • Question

  • I am new to wpf. i have database table.Name is Constants contain two fields id and value.

    id value

    1  xyz

    2 msdn

    3 developers

    4 technologies

    value contain 4 rows. i am having 4 textboxes.i want to bind 4 values to 4 textboxes.when i run the code it will display.i am trying below but does't wok

     <Label Name="

    lblCNReports" Content="1.  Company-name-reports" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="67" Width="158"/>
                <TextBox Name="txtCNReports"  Text="{Binding SystemConstant.Value, Mode=TwoWay}" MaxLength="100" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="67" TabIndex="1"  MinHeight="15">
                    <i:Interaction.Behaviors>
                        <vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
                    </i:Interaction.Behaviors>
                </TextBox>

                <Label Name="lblCNDisplay" Content="2.  Company-Name-Display" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="94" />
                <TextBox Name="txtCNDisplay" Text="{Binding SystemConstant.Value, Mode=TwoWay}" MaxLength="200" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="94" TabIndex="2"   MinHeight="15">
                    <i:Interaction.Behaviors>
                        <vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
                    </i:Interaction.Behaviors>
                </TextBox>

                <Label Name="lblAddress1" Content="3.  Address-1" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="121"/>
                <TextBox Name="txtAddress1" Text="{Binding SystemConstant.Value, Mode=TwoWay}" MaxLength="150" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="121"  TabIndex="3"  MinHeight="15" >
                    <i:Interaction.Behaviors>
                        <vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
                    </i:Interaction.Behaviors>
                </TextBox>

                <Label Name="lblAddress2" Content="4.  Address-2" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="150"/>
                <TextBox Name="txtAddress2" Text="{Binding SystemConstant.Value, Mode=TwoWay}" MaxLength="200" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="146"  TabIndex="4" MinHeight="15" IsEnabled="False">
                    <i:Interaction.Behaviors>
                        <vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
                    </i:Interaction.Behaviors>
                </TextBox>

    my ViewModel is

     public class ControlFileViewModel: ViewModelBase

    {

     public SystemConstant SystemConstant
            {
                get { return _SystemConstant; }
                set
                {
                    if (value != _SystemConstant)
                    {
                        _SystemConstant = value;
                        RaisePropertyChanged("SystemConstant");

                    }
                }
            }
            public ObservableCollection<SystemConstant> SystemConstants //read only
            {
                get { return _SystemConstants; }
                set
                {
                    if (value != _SystemConstants)
                    {
                       _SystemConstants = value;
                        RaisePropertyChanged("SystemConstants");
                    }
                }
            }
            public string Value
            {
                get { return SystemConstant.Value; }
                set
                {
                    if (value == SystemConstant.Value) return;
                    SystemConstant.Value = value;
                        RaisePropertyChanged("Value");

                    }
                }
    }

    I want to display as

    txtcnreports.text=value[1];

    txtdisplay.text=value[2];

    txtADDRESS.TEXT=VALUE[3];

    txtcity.text=value[4];


                                
    Thursday, November 24, 2016 5:21 AM

Answers

  • First, this forum is dedicated to Expression Design, a graphics editing application, not a WPF or programming environment.

    Second, this is an ASP.NET question, and you would be best served asking it in the appropriate forum, at forums.asp.net.

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    • Edited by paladyn Friday, November 25, 2016 4:17 AM
    • Marked as answer by kavyabathineni Friday, November 25, 2016 6:03 AM
    Friday, November 25, 2016 4:16 AM