How To binding Database row values to TextBoxes WPF MVVM

Nov 23 2016 10:03 AM

i am new to WPF Mvm Entity frame work. i am having table SystemConstants contain 3 columns id,name,value.

valuecontain 29 rows. These 29 rows bind to 29 textboxex in xmal file How Bind lease help me. i am trying but when i run the code database value not binding to textbox
 
 my xaml code is
 
<Label Name="lblCNDisplay" Content="2. Company-Name-Display" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="94" />
<TextBox Name="txtCNDisplay" Text="{Binding SystemConstant.Company-name-display, 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 Order.Customer.AddressLine1, 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 Order.Customer.AddressLine2, 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>
<Label Name="lblCity" Content="5. City" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="176"/>
<TextBox Name="txtCity" Text="{Binding Order.Customer.City, Mode=TwoWay}" MaxLength="100" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="173" TabIndex="5" MinHeight="15" >
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblState" Content="6. State" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="200"/>
<TextBox Name="txtState" Text="{Binding Order.Customer.BusinessContact, Mode=TwoWay}" MaxLength="50" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="200" TabIndex="6" MinHeight="15" >
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblZipCode" Content="7. Zip-Code" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="228"/>
<TextBox Name="txtZip" Text="{Binding Order.Customer.ContactName, Mode=TwoWay}" MaxLength="200" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="228" TabIndex="7" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
<vmHelper:TextBoxInputMaskBehavior InputMask="99999-0000 " PromptChar="_"/>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblPhnNum" Content="8. Phone-Number" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="255"/>
<TextBox Name="txtPhnNum" Text="{Binding Order.Comments, Mode=TwoWay}" Width="170" MaxLines="3" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="255" TabIndex="8" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
<vmHelper:TextBoxInputMaskBehavior InputMask="999/000-000 " PromptChar="_"/>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblFaxNum" Content="9. Fax-Number" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="281"/>
<TextBox Name="txtFaxNum" Text="{Binding Order.RouteCode, Mode=TwoWay}" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="281" TabIndex="9" MinHeight="15" >
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
<vmHelper:TextBoxInputMaskBehavior InputMask="999/000-000 " PromptChar="_"/>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblNextRepNum" Content="10. Next-Report-Number" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="307"/>
<TextBox Name="txtNextRepNum" Text="{Binding Order.Terms_Description, Mode=TwoWay}" MaxLength="15" Width="170" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="307" TabIndex="10" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
<vmHelper:TextBoxInputRegExBehaviour RegularExpression="^(\d*)\.{0,1}(\d*)$" MaxLength="15" />
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany2" Content="11. Company-2" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="334"/>
<TextBox Name="txtCompany2" Width="190" MaxLength="200" MinHeight="15" Text="{Binding Order.Invoice_Date, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="334" TabIndex="11" >
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany3" Content="12. Company-3" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="360"/>
<TextBox Name="txtCompany3" Width="190" MaxLength="200" Text="{Binding SalesRepName, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="360" TabIndex="12" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany4" Content="13. Company-4" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="387"/>
<TextBox Name="txtCompany4" Text="{Binding Order.Print_Order_Labels, Mode=TwoWay}" MaxLength="200" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="387" TabIndex="13" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany5" Content="14. Company-5" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="414"/>
<TextBox Name="txtCompany5" Text="{Binding Order.Order_TakenBy, Mode=TwoWay}" MaxLength="200" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="414" TabIndex="14" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany6" Content="15. Company-6" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="444"/>
<TextBox Name="txtCompany6" Text="{Binding Order.Tax_Code, Mode=TwoWay}" MaxLength="200" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="442" TabIndex="15" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany7" Content="16. Company-7" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="469"/>
<TextBox Name="txtCompany7" Text="{Binding Order.PO_Number, Mode=TwoWay}" MaxLength="200" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="469" TabIndex="16" MinHeight="15">
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
<Label Name="lblCompany8" Content="17. Company-8 " HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="22" Canvas.Top="496"/>
<TextBox Name="txtCompany8" Width="190" MaxLength="200" MinHeight="15" Text="{Binding Order.Ship_Date, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="185" Canvas.Top="496" TabIndex="17" >
<i:Interaction.Behaviors>
<vmHelper:KeyUpWithArgsBehavior KeyUpCommand="{Binding KeyUPCommand}" ></vmHelper:KeyUpWithArgsBehavior>
</i:Interaction.Behaviors>
</TextBox>
 
 

Answers (6)