CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Dynamic Binding of Property to PropertyStatus Causes PropertyStatus Not to Show

    rated by 0 users
    Not Answered This post has 0 verified answers | 0 Replies | 1 Follower

    Not Ranked
    1 Posts
    Nitronie posted on Thu, Jun 28 2012 3:40 PM

    Hey,

    I'm developing a form to edit the properties of one of my Business Objects in Silverlight, and since each property is displayed for editing much the same way, I was trying to make the job easier by making a custom UserControl that would display the FriendlyName in a TextBlock, the actual String in the property in a TextEdit (using DevExpress control, but I assume this is the same name for normal TextBoxes), and then a PropertyStatus for the Property next to the TextEdit. 

    I got this working with TwoWay Binding on the form, but when I tried to pull it out into a seperate UserControl for DRY, only the PropertyStatus is not updating and showing the error. I know it has the error, because when I debugged it and hovered over the name of the PropertyStatus in the code-behind it showed that the object had correctly picked up the error, it just wasn't displaying it. 

    I'm using the following code to accomplish this:

     

    Since I was having problems binding the property to the different UserControls in the XAML, I pulled it into the code behind using the following method:

     

    public void SetupBindings(Csla.PropertyInfo<String> property, Object dataContext)

            {

                this.propertyNameLabel.Text = property.FriendlyName + ":";

     

                //set up binding object

                Binding b = new Binding();

                b.Path = new PropertyPath(property.Name);

                b.Mode = BindingMode.TwoWay;

                b.Source = dataContext;

     

                this.propertyNamePropertyStatus.SetBinding(Csla.Xaml.PropertyStatus.PropertyProperty, b);

                this.propertyNameTextEditor.SetBinding(DevExpress.Xpf.Editors.TextEdit.TextProperty, b);

            }

     

     

     

    Then the form (the parent of the custom control) calls the method like this:

     

    public FormView()

            {

                InitializeComponent();  

                this.DataContextChanged += new DependencyPropertyChangedEventHandler(FormView_DataContextChanged);

            }

     

    void FormView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)

            {

                this.propertyTextEditorControl.SetupBindings(

                   MyCslaLibrary.MyObject.MyPropertyProperty, this.DataContext);

            }

     

     

    The DevExpress TextEdit will display the Validation Error just fine, but I don't like the way it does, and it doesn't display warning, information, and busy status, so I'd really rather use the PropertyStatus control, but it's not working. Please help.

     

    Page 1 of 1 (1 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems