PropertyStatus can't update status

PropertyStatus can't update status

Old forum URL: forums.lhotka.net/forums/t/10653.aspx


simon posted on Tuesday, August 30, 2011

I have a BusinessListBase<MaterialCategorys, MaterialCategory>, in which  i add a method  as below:

  public MaterialCategory  AddRootNode()

        {

            MaterialCategory item= MaterialCategory.NewMaterialCategory();

            this.Add(item);

            return item;

        }

in the child BO, I add the OnUnknownPropertyChanged() 

 [Csla.RunLocal]

        protected override void Child_Create()

        {

            LoadProperty(IdProperty, System.Threading.Interlocked.Decrement(ref _lastID));

            LoadProperty(DescriptionProperty, "Test");

            BusinessRules.CheckRules();

            OnUnknownPropertyChanged();

            base.Child_Create();

        }

 BusinessRules.AddRule(new Csla.Rules.CommonRules.Required(NameProperty));

 

but I invoke the method AddRootNode, the UI work well except the propertystatus.

I use ViewModel<MaterialCategory>. in which i invoke the method:

 

        private  void AddRootNode()

        {

           var SelectedItem= Model.AddRootNode();

        }

the csla version is 4.2.

JonnyBee replied on Tuesday, August 30, 2011

How do you bind PropertyStatus to the BO?

You should define DataContext either on each PropertyStatus or the Xaml container.

simon replied on Tuesday, August 30, 2011

In my view:

 

  <TabControl Grid.Row="1"  Name="tabControl1"  >

            <TabItem Header="Overview" Name="tabItem1">

                <!--local:MaterialCategoryListView DataContext="{Binding}"/-->

                <TreeView Name="CategoryTreeView" ItemsSource="{Binding Path=Model}"  

                 ItemTemplate ="{StaticResource NavigationTemplate }" >

                    <TreeView.ItemContainerStyle>

                        <!-- This Style binds a TreeViewItem to a PersonViewModel.  -->

                        <Style TargetType="{x:Type TreeViewItem}">

                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />

                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

                            <Setter Property="FontWeight" Value="Normal" />

                            <Style.Triggers>

                                <Trigger Property="IsSelected" Value="True">

                                    <Setter Property="FontWeight" Value="Bold" />

                                </Trigger>

                            </Style.Triggers>

                        </Style>

                    </TreeView.ItemContainerStyle>

 

                </TreeView>

            </TabItem>

            <TabItem Header="Base" >

                <local:MaterialCategoryBaseView DataContext="{Binding ElementName=CategoryTreeView, Path=SelectedItem}"/>

            </TabItem>

        </TabControl>

in the MaterialCategoryBaseView :

<csla:PropertyStatus Grid.Column="2" Margin="11,11,86,3" Name="propertyStatus1" Width="20" Height="20" Property="{Binding Path=Name }" />

 

When I add the new item, i first click the row, and shift to the tab "Base",  the error doesn't appear. 

if i move  the focus to  another row and then back to the new row, the error will present 

JonnyBee replied on Tuesday, August 30, 2011

If  you are using the Csla 4.2 Alpha then you should update to the latest Csla.Xaml.PropertyStatus from trunk.

PropertyStatus would miss updating UI if a control is not visible when page is shown (ie non visible tab page).

 

Copyright (c) Marimer LLC