Tech Off Thread

6 posts

WPF : anchor doesn't work?

Back to Forum: Tech Off
  • User profile image
    turrican

    I set statusbar HAlign to stretch and VAlign to bottom but...



  • User profile image
    jh71283

    Try Width="Auto"

  • User profile image
    turrican

    jh71283 said:
    Try Width="Auto"

    Thanks, it worked. But omfg, WPF sucks big time so far. Totally unnatural/unlogical compared to what "we are used to" from winforms.

  • User profile image
    Cannot​Resolve​Symbol

    turrican said:
    jh71283 said:
    *snip*
    Thanks, it worked. But omfg, WPF sucks big time so far. Totally unnatural/unlogical compared to what "we are used to" from winforms.
    FWIW, if you don't specify a width at all (and no other positioning/sizing properties besides the height and vertical alignment at the bottom), WPF will make the status bar automatically resize like you'd expect it to.  This is the XAML generated by Blend for a window only containing a status bar, and it resizes as expected:

    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="TestStatusbar.Window1"
        x:Name="Window"
        Title="Window1"
        Width="640" Height="480">

        <Grid x:Name="LayoutRoot">
            <StatusBar VerticalAlignment="Bottom" Height="26" Background="#FF5F7CAD"/>
        </Grid>
    </Window>

  • User profile image
    brian.​shapiro

    CannotResolveSymbol said:
    turrican said:
    *snip*
    FWIW, if you don't specify a width at all (and no other positioning/sizing properties besides the height and vertical alignment at the bottom), WPF will make the status bar automatically resize like you'd expect it to.  This is the XAML generated by Blend for a window only containing a status bar, and it resizes as expected:

    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="TestStatusbar.Window1"
        x:Name="Window"
        Title="Window1"
        Width="640" Height="480">

        <Grid x:Name="LayoutRoot">
            <StatusBar VerticalAlignment="Bottom" Height="26" Background="#FF5F7CAD"/>
        </Grid>
    </Window>
    CannotResolveSymbol,

    wouldn't it make sense to use a DockPanel instead of a Grid

  • User profile image
    Cannot​Resolve​Symbol

    brian.shapiro said:
    CannotResolveSymbol said:
    *snip*
    CannotResolveSymbol,

    wouldn't it make sense to use a DockPanel instead of a Grid
    Probably, but I was just seeing what Blend spat out when I tried to make a status bar, so I didn't bother to put it in a DockPanel (Blend projects start out with a Grid in the document).

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.