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.
Grid
- is it important to reproduce the problem? - VladD