This is a migrated thread and some comments may be shown as answers.

Binding in DataTemplate does not work unless style is applied

5 Answers 148 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 18 Jun 2014, 12:46 AM
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. 

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 19 Jun 2014, 01:49 PM
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.
 
0
Nick
Top achievements
Rank 1
answered on 19 Jun 2014, 11:28 PM
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.
0
Dimitrina
Telerik team
answered on 20 Jun 2014, 02:04 PM
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.
 
0
Nick
Top achievements
Rank 1
answered on 24 Jun 2014, 06:49 AM
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.
0
Dimitrina
Telerik team
answered on 24 Jun 2014, 07:51 AM
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.
 
Tags
PropertyGrid
Asked by
Nick
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Nick
Top achievements
Rank 1
Share this question
or