Parent property name with nested properties not updating

5 posts, 1 answers
  1. Zberbang
    Zberbang avatar
    13 posts
    Member since:
    Oct 2013

    Posted 30 Dec 2013 Link to this post

    Hello!

    I encountered the problem with parent property name which not updates if I modify child properties.
    I have a class which overrides ToString() to return format string of its properties. When I change one of that property I fire PropertyChanged but ToString() never calling again and I see old name of parent property on GUI.
    But the name is changing and ToString() is calling on each expanding/collapsing or searching.

    Is it by desing or I have to do smth extra?

    Here is a sample project with Q2 2013 libs to illustrate the problem.
  2. Zberbang
    Zberbang avatar
    13 posts
    Member since:
    Oct 2013

    Posted 09 Jan 2014 Link to this post

    Hi Hristo,
    thanks for explanation.
    I have similar issue with collection editor - object name in left area is not refreshing on object changes.
    I modified sample project to let Order have list of Employee. The only way to refresh Employee name in left area is to toggle parent object property Employees.

    What should I do this time?

    Here is a sample project.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Hristo
    Admin
    Hristo avatar
    41 posts

    Posted 14 Jan 2014 Link to this post

    Hi Zber,

    Basically when you edit the item properties, you don't send notifications to the parent that it's children have changed. You would have to implement an ObservableCollection of INotifyPropertyChanged.

    You can see a demonstration of this in our online demo located here. Additional information about Collection editor is located here.

    Regards,
    Hristo
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Zberbang
    Zberbang avatar
    13 posts
    Member since:
    Oct 2013

    Posted 15 Jan 2014 Link to this post

    Hi Christo,

    Implementing an ObservableCollection of INotifyPropertyChanged won't cause correct updating object name on the left area.
    You give me a link for silverlight demo and it's work as should but WPF demo don't.
    I found the difference between two demos and found that silverlight version is changing template of CollectionEditorStyle:
    <Style TargetType="telerik:CollectionEditor" BasedOn="{StaticResource CollectionEditorStyle}">
    <Setter Property="ItemTemplate">
    <Setter.Value>
    <DataTemplate>
    <TextBlock Text="{Binding PropertyName}" />
    </DataTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    So that is the key to solve my problem.
  6. Answer
    Hristo
    Admin
    Hristo avatar
    41 posts

    Posted 17 Jan 2014 Link to this post

    Hello Zber,

    You will have to use the following style to update the UI when the first or last name is updated:
    <Style TargetType="telerik:CollectionEditor">
         <Setter Property="ItemTemplate">
             <Setter.Value>
                 <DataTemplate>
                     <TextBlock>
                         <TextBlock.Text>
                             <MultiBinding  StringFormat="{}{0}, {1} - {2}">
                                 <Binding Path="LastName"/>
                                 <Binding Path="FirstName"/>
                                 <Binding Path="Department.Country"/>
                             </MultiBinding>
                         </TextBlock.Text>
                     </TextBlock>
                 </DataTemplate>
             </Setter.Value>
         </Setter>
     </Style>

    You can find more information about the string format property in the following article in msdn: article.

    Regards,
    Hristo
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready