Implicit Style for TreeView with setting TextDrop properties causes error

5 posts, 1 answers
  1. Li
    Li avatar
    46 posts
    Member since:
    Feb 2011

    Posted 15 Jun 2012 Link to this post

    Hi Telerik Team,

    we are using Telerik Version 2011 Q3 and we are using SL 4.

    In our application we define an implicit Style for the RadTreeView:

    <Style TargetType="telerik:RadTreeView">
           <Setter Property="TextDropAfter" Value="{Binding Source={StaticResource TreeViewStrings}, Path=TreeViewDropAfter}"></Setter>
            <Setter Property="TextDropBefore" Value="{Binding Source={StaticResource TreeViewStrings}, Path=TreeViewDropBefore}"></Setter>
            <Setter Property="TextDropIn" Value="{Binding Source={StaticResource TreeViewStrings}, Path=TreeViewDropIn}"></Setter>
            <Setter Property="TextDropRoot" Value="{Binding Source={StaticResource TreeViewStrings}, Path=TreeViewDropRoot}"></Setter>     
    </Style>

    The binded properties of the static resource TreeViewStrings can change and fire an property changed event, when the language of the application has changed (dynamic localization).

    We compile our application for Silverlight 4. When the plugin for SL 5 is used, this style works fine. When the plugin for SL 4 is used, it causes an error and the application cannot be started. The error occurs during InitializeComponents in the App constructor:
    System.Windows.Markup.XamlParseException occurred
      Message=Das Festlegen von Eigenschaft '' hat eine Ausnahme ausgelöst. [Line: 9 Position: 44]
      LineNumber=9
      LinePosition=44
      StackTrace:
           bei System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
           bei ACO.Portal.App.InitializeComponent()
           bei ACO.Portal.App..ctor()
      InnerException: System.NotSupportedException
           Message=Die schreibgeschützte Eigenschaft  '' kann nicht festgelegt werden.
           StackTrace:
                bei MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
                bei MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)
           InnerException:

    Can you tell me whether this is a Silverlight bug or am I doing anything wrong?
    When I set the TextDropAfterProperty (and the other three text properties) to a constant string in the Style, everything works fine.

    I suppose this to be an SL 4 bug, because it works with the SL 5 plugin, but we have to use the SL 4 plugin (our customer uses it).

    I found a solution which works, I am setting an attached property in the implicit style and in the OnPropertyChanged method of this attached property, I set the bindings to the TreeView properties, so I can handle this, but I want to know, what is the problem (SL bug, a mistake I do or what ever) because this is a complicated way to achieve the wished effect.

    Thanks and Kind regards,
    Li

  2. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 20 Jun 2012 Link to this post

    Hello,

    SL4 does not support style bindings. Instead you should use Telerik's ContainerBindings (or other equivilent). In SL5 and WPF you can use style bindings and they shall work as expected.
    You could take a look at this article about container bindings: http://www.telerik.com/help/silverlight/radtreeview-how-to-bind-hierarchical-data-use-containerbindingcollection.html 

    Hope this helps.

    All the best,
    Hristo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Li
    Li avatar
    46 posts
    Member since:
    Feb 2011

    Posted 20 Jun 2012 Link to this post

    I set some strings in an own RadGridView as I described in my first post and this works fine. It does not work in the RadTreeViewStyle.

    I do not understand why I should use ContainerBindings to set the string properties TextDropAfter, TextDropBefore, TextDropIn and TextDropRoot. This has nothing to do with the hierarchical structure from my point of view. Could you give me a hint?

    Kind regards,
    Li
  5. Answer
    Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 25 Jun 2012 Link to this post

    Hi Li,

    The hierarchical structure has nothing to do in common with these properties or the binding. I'm trying to say that SL4 does not support style bindings and SL5 does support them. You could take a look at following post from Microsoft stating the difference: http://msdn.microsoft.com/en-us/library/gg986857(v=vs.95).aspx .

    If I got you right, you must use SL4, thus you could not use the style binding feature. We have provided a custom alternative implementation - the container bindings. I'm not saying you should use container bindings at all cost, but it is a nice replacement of missing style bindings feature in SL4.

    Hope this helps. Please let me know if I did not get your question right or you need further assistance. Also a sample project would be the best approach to grasp your issue with most details.

    On a side note, I just wanted to encourage you to take advantage of the support ticketing system (http://www.telerik.com/account/support-tickets/new-support-ticket.aspx) in cases when you need a prompt response to urgent issues. This is the best way to reach our support staff or attach a sample project.

    Regards,
    Hristo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Li
    Li avatar
    46 posts
    Member since:
    Feb 2011

    Posted 29 Jun 2012 Link to this post

    Hi Hristo,

    thank you for the clarification.

    I will have a look to the given link.
    As I have a solution found for my issue, as I described in the first post, I will use it until our customer will switch to SL 5.

    Thank you for the hint to the ticket system, I will use it next time.

    Kind regards,
    Li
Back to Top
DevCraft banner