Binding in DataTemplate does not work unless style is applied

6 posts, 0 answers
  1. Nick
    Nick avatar
    14 posts
    Member since:
    Jun 2013

    Posted 17 Jun 2014 Link to this post

    I've spent the last day tracking down a weird bug. I copy/pasted an existing PropertyDefinition into a new View but it just did not work. The values were not displaying. I finally tracked it down.

    My definitions are:

    <!-- This one works  -->
    <PropertyGrid:PropertyDefinition Binding="{Binding Stock.Name}" GroupName="Stock" DisplayName="Name" OrderIndex="9" />
    <!-- This one does not show any text, even the FallbackValue when I intentionally mistype the binding path  -->
    <PropertyGrid:PropertyDefinition Binding="{Binding Stock.Name}" GroupName="Stock" DisplayName="Name" OrderIndex="10">
      <PropertyGrid:PropertyDefinition.EditorTemplate>
        <DataTemplate>
          <TextBlock Text="{Binding Stock.Name, TargetNullValue='The value is null', FallbackValue='Problem getting text'}" />
        </DataTemplate>
      </PropertyGrid:PropertyDefinition.EditorTemplate>
    </PropertyGrid:PropertyDefinition>

    As you can see in the comments the controls are basically identical, the only difference is the 2nd one has a DataTemplate with a TextBlock in it. This TextBlock is completely empty.

    I finally found the one difference between my views that fixed the problem.

    <UserControl.Resources>
      <Style TargetType="Controls2:RadPropertyGrid">
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
      </Style>
    </UserControl.Resources>

    I'm just wondering why this matters. Is it a bug? Did I leave something important out and this triggers it? Adding the above property directly to the control does not fix it - only when we use a Style.

    Note that the controls in the DataTemplate will render, e.g. if I set Background="Red", but the Text will not display even if it is hard coded to a string. 
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Jun 2014 Link to this post

    Hi Nick,

    I tested defining similar PropertyDefinition (the one that does not work for you), however, everything works fine on my end. I tested with our latest version.

    What version do you use? Is there anything else specific to your implementation? Would it be possible for you to isolate the issue in a demo solution and send it to me so that I can check it locally?

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Nick
    Nick avatar
    14 posts
    Member since:
    Jun 2013

    Posted 19 Jun 2014 in reply to Dimitrina Link to this post

    Hi Didie,

    We are on 2014.1 and the only other thing that I left out is that initially the binding object is null until the user clicks on a list to select the item. The other properties update but this does not. However, when I use a plain text string, it doesn't show either so I'm not sure if this matters.

    I will see if I can make a standalone project but since we have a workaround it might need to wait.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Jun 2014 Link to this post

    Hi Nick,

    I attached my test project. Would you please try changing it to correspond to your specific setup? 

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Nick
    Nick avatar
    14 posts
    Member since:
    Jun 2013

    Posted 24 Jun 2014 in reply to Dimitrina Link to this post

    Hi Didie

    I just realised I had both forums open and posted in this one by mistake. My project is Silverlight! :(

    Anyway I have tried to isolate it in a smaller project but the bug does not occur. I think it is something to do with the themes we are using but it's all very interwoven so is a bit hard to figure out. I won't be able to look at this for a while but will try when I get time.
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 Jun 2014 Link to this post

    Hi,

    You can try removing all the additional styling you have added. If this resolves the issue, then, it is definitely some setting causing the problem. You should then isolate the lines you have applied to figure out the reason. 
    Have you eventually set a value for ScrollViewer.HorizontalScrollBarVisibility somewhere?

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready