code_junkie

Size-to-content-layout problem in WPF

Nov 12th, 2011
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <Window x:Class="SO1.Window1"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. Title="Window1" SizeToContent="Width" FontSize="20">
  5. <DockPanel>
  6. <Button DockPanel.Dock="Top">A rather long text</Button>
  7. <TextBlock TextWrapping="Wrap">Short text</TextBlock>
  8. </DockPanel>
  9. </Window>
  10.  
  11. <Button x:Name="btn" DockPanel.Dock="Top">Short text</Button>
  12. <TextBlock TextWrapping="Wrap"
  13. MaxWidth="{Binding ElementName=btn,Path=ActualWidth}">A rather long text</TextBlock>
Add Comment
Please, Sign In to add comment