Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WPF DataBinding
Message
From
21/07/2008 12:17:08
 
 
To
21/07/2008 12:13:04
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Miscellaneous
Thread ID:
01332836
Message ID:
01332839
Views:
6
I found it. I should have been retrieving the SerialNumber, then assigning the business object reference to the BindingContext property.

>I cannot get databinding to work for my WPF textbox controls. Here is a partial listing of the XAML for the form based on mmBusinessWindow. As you can see, I have set the Datacontext on the outter Stack Panel control and set the Binding Path for the Text Property on each textbox control.
>
>
>    <Grid x:Name="LayoutRoot">
>        <StackPanel Margin="8,8,21,20" x:Name="stackPanel1">
>            <StackPanel.DataContext>
>                <PIComponents_Enterprise_SerialNumbers_BusinessObjects:SerialNumbers/>
>            </StackPanel.DataContext>
>            <StackPanel Height="35" x:Name="stackPanel2" Width="296" Orientation="Horizontal">
>                <Label Height="28" x:Name="lblJobNumber" Width="120" Content="Job Number:"/>
>                <TextBox Height="23" x:Name="txtJobNumber" Width="120" IsEnabled="False" Text="{Binding Path=Entity.JobNumber, Mode=Default}" />
>            </StackPanel>
>            <StackPanel Height="35" x:Name="stackPanel3" Width="296" Orientation="Horizontal">
>                <Label Height="28" x:Name="lblSerialNumber" Width="120" Content="Serial Number:"/>
>                <TextBox Height="23" x:Name="txtSerialNumber" Width="120" IsEnabled="False" Text="{Binding Path=Entity.SerialNumber, Mode=Default}" />
>            </StackPanel>
>            <StackPanel Height="35" x:Name="stackPanel4" Width="296" Orientation="Horizontal">
>                <Label Height="28" x:Name="lblDateCreated" Width="120" Content="Date Created:"/>
>                <TextBox Height="23" x:Name="txtDateCreated" Width="120" IsEnabled="False" Text="{Binding Path=Entity.DateCreated, Mode=Default}" />
>            </StackPanel>
>            <StackPanel Height="35" x:Name="stackPanel5" Width="296" Orientation="Horizontal">
>                <Label Height="28" x:Name="lblScrapped" Width="120" Content="Scrapped:"/>
>                <TextBox Height="23" x:Name="txtScrapped" Width="120" IsEnabled="False" Text="{Binding Path=Entity.Scrapped, Mode=Default}" />
>            </StackPanel>
>      </StackPanel>
>   </Grid>
>
>
>Now for the code in the window. Here I am setting the stackPanel1 DataContext property. In the debugger, I can see the values in the DataContext property, but they are not displaying in the textbox controls.
>
>
>    public partial class ViewSerialNumberHistoryForm : mmBusinessWindow
>    {
>        BusinessObjects.SerialNumbers bizSerialNumbers;
>
>        /// <summary>
>        /// Constructor
>        /// </summary>
>        private ViewSerialNumberHistoryForm()
>        {
>            this.InitializeComponent();
>        }
>
>        public ViewSerialNumberHistoryForm(Guid pkSerialNumber)
>        {
>            this.bizSerialNumbers = (BusinessObjects.SerialNumbers)this.RegisterPrimaryBizObj(new BusinessObjects.SerialNumbers());
>            this.bizSerialNumberHistory = (SerialNumberHistory)this.RegisterBizObj(new SerialNumberHistory());
>
>            this.InitializeComponent();
>
>            this.stackPanel1.DataContext = this.bizSerialNumbers.GetSerialNumberByPK(pkSerialNumber);
>        }
>    }
>
>
>What am I missing?
Thanks,
Dan Jurden
djurden@outlook.com
Previous
Reply
Map
View

Click here to load this message in the networking platform