I implement a log on similarity of it

Made a similar DataTemplate :

  <DataTemplate DataType="{x:Type core:TimedLog}"> <Grid IsSharedSizeScope="True"> <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup="Date" Width="Auto"/> <ColumnDefinition SharedSizeGroup="Message" Width="Auto"/> </Grid.ColumnDefinitions> <TextBlock Text="{Binding DateTime, StringFormat={}{0:MM-dd-yyyy HH:mm:ss:}}" Grid.Column="0"/> <TextBlock Text="{Binding Message}" Grid.Column="1" TextWrapping="Wrap"/> </Grid> </DataTemplate> 

And, by analogy, I made the log space itself (Basically, I just made ScrollViever for ItemControl , so that the scrolling would not jump on the elements, otherwise I would not even see the subsequent log levels)

  <ScrollViewer CanContentScroll="True"> <ItemsControl ItemsSource="{Binding}" Padding="8,5,0,5" Margin="0"> <ItemsControl.Template> <ControlTemplate> <ItemsPresenter/> </ControlTemplate> </ItemsControl.Template> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel IsItemsHost="True"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </ScrollViewer> 

And everything seems to be good, but the log line has stopped adjusting the height and the text on the first line is cut off. I thought maybe due to the fact that ScrollViever , TimedLog went outside the screen, but I checked it in Realtime and the width is correct. Just stopped carrying. What could be the problem?

UPD: If you add a fixed width to the TextBlock , the transfer works.

  • Could you please trim the example to a minimum? For example, an external Grid - is it important to reproduce the problem? - VladD
  • @VladD, well, maybe it was important, a little. Updated - BwehaaFox
  • Well, so you would have experimented. Otherwise, it will have to do to someone who will try to answer. - VladD
  • @VladD I do not think that it is important as it is, but it was necessary to indicate something clearly there. - BwehaaFox

1 answer 1

The answer lurked in this block:

 <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup="Date" Width="Auto"/> <ColumnDefinition SharedSizeGroup="Message" Width="Auto"/> </Grid.ColumnDefinitions> 

In the second ColumnDefinition it was necessary to remove SharedSizeGroup="Message" and Width="Auto" and auto-transfer began to work:

 <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup="Date" Width="Auto"/> <ColumnDefinition /> </Grid.ColumnDefinitions>