I have a TextBlock which is resizing itself depending on its Text which is causing my entire window to resize. I want the text to truncate instead - but I don't want to explicitly set the MaxWidth of the TextBlock in case the user resizes the window.
Before import button pressed:
Current output:
Desired output:
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Name="status" Margin="3" HorizontalAlignment="Stretch" TextTrimming="CharacterEllipsis"></TextBlock>
<Label Name="lblPercentage" Grid.Colum开发者_开发百科n="1" HorizontalAlignment="Right" ></Label>
<Button Grid.Column="2" Margin="3" Name="cmdImport" Click="import_Click" HorizontalAlignment="Right">Import</Button>
<Button Grid.Column="3" Margin="3" Name="cmdCancel" Click="cancel_Click" HorizontalAlignment="Right">Close</Button>
</Grid>
Just don't set SizeToContent
on your Window
.
精彩评论