Search code examples
c#wpfxamlwrappanel

Break newline if bind is very long


I have a wrap panel 3 binding, the second bind is very short, and the third bind very long, and in the wrap panel (3 bind) we moved to a new line. How to stay in the same row. A wrap panle suits me just fine doing a lot of possibilities. I can not use other panel.

<WrapPanel x:Name="WrapPrvi"  Orientation="Horizontal" Grid.Row="9" Grid.Column="1">
  <TextBlock TextWrapping="Wrap" Text="xxxxx " FontFamily="Times New Roman" 
             FontSize="16" />
  <TextBlock TextWrapping="Wrap" Text="{Binding Info.Municipality.Tijelo2}" 
             FontFamily="Times New Roman" FontSize="16" FontWeight="Bold" />
  <TextBox x:Name="Pream" TextWrapping="WrapWithOverflow" 
           Text="{Binding Register.Preambula, Mode=TwoWay, 
                  UpdateSourceTrigger=PropertyChanged}" Height="95.862" 
            Width="702.407" FontFamily="Times New Roman" FontSize="16" />
</WrapPanel>

Solution

  • First, remove the Wrapping:

    <TextBox x:Name="Pream"  
           Text="{Binding Register.Preambula, Mode=TwoWay, 
                  UpdateSourceTrigger=PropertyChanged}" Height="95.862" 
            Width="702.407" FontFamily="Times New Roman" FontSize="16" />
    

    Then, if the text is not displayed in full, check if the WrapPanel's width is in some way defined, maybe in the grid column.