wyvern010
Topic Author
Posts: 14
Joined: 18 Apr 2019, 13:41

TextBlock inside Textblock wont Bind to Data/show.

10 May 2019, 11:03

The following code works on WPF, but not in NoesisApp.
DataContext is set to the userconrol from code behind.
this works, cus it is working for other elements.

.xaml
<Grid Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center">
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="80"/>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
  </Grid.ColumnDefinitions>
  <TextBlock Text="Room: " Style="{StaticResource TextColor}" Grid.Column="1">
    <TextBlock Text="{Binding Room[0].Name}" Style="{StaticResource TextColor}" Grid.Column="1"/>
  </TextBlock>
  <TextBlock Text="{Binding Room[0].Date}" Grid.Column="2" Style="{StaticResource TextColor}" TextAlignment="Right" Padding="20,0"></TextBlock>
</Grid>

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1628
Joined: 22 Dec 2011, 19:20

Re: TextBlock inside Textblock wont Bind to Data/show.

11 May 2019, 18:46

This is a bug in our parser that is not able to add inner TextBlock as an inline, you should be getting an error message about that:
Can't add a 'TextBlock' to a 'InlineCollection'
In WPF the parser creates an InlineUIContainer to wrap the inner TextBlock so it can be added to the outer TextBlock. Could you please report this in our bugtracker and we will fix it in a future release?

In the meantime you can use a Run instead of a TextBlock for the inner text, I recommend to do that anyway because it is a bit more efficient:
<TextBlock Text="Room: " Style="{StaticResource TextColor}" Grid.Column="1">
    <Run Text="{Binding Room[0].Name}"/>
</TextBlock>

Who is online

Users browsing this forum: No registered users and 5 guests