WPF StatusBar Update Paradigm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ClubbieTim
    New Member
    • Jun 2007
    • 2

    WPF StatusBar Update Paradigm

    I have an event that I would like to sandwich with "Loading... " and "Ready!" textblocks on my status bar. This is on a WPF application (as opposed to a web app).

    This would be simply on a Windows Form, but in the world of WPF I am having an existential crisis.

    Here's the jist:

    XAML
    [code=xml]
    <!--StatusBar-->
    <StatusBar Height="30" Name="MasterSta tusBar" VerticalAlignme nt="Bottom" >
    <StatusBarIte m Name="StatusBar Status">
    <TextBlock Name="Status">W ork</TextBlock>
    </StatusBarItem>
    </StatusBar>

    <!--Button-->
    <Button HorizontalAlign ment="Right" Margin="0,116,1 51,122" Name="button1" Width="75" Click="button1_ Click">Button</Button>
    [/code]

    C#
    [code=cpp]
    private void button1_Click(o bject sender, RoutedEventArgs e)
    {
    StatusBarItem StatusBarItem = (StatusBarItem) MasterStatusBar .FindName("Stat usBarStatus");
    TextBlock txt = (TextBlock)Stat usBarItem.FindN ame("Status");

    txt.Text = "Loading... ";

    //Some long process
    Thread.Sleep(15 00);

    txt.Text = "Ready";

    }
    [/code]

    Any suggestions would be greatly appreciated.
    Last edited by Frinavale; Dec 15 '08, 03:53 PM. Reason: added [code] tags
  • blackandcold

    #2
    I know it's an old post but:

    You can access your textblock defined in the XAML document by giving a name.
    So you only have to set:
    Code:
    Status.Text = "Ready";

    Comment

    Working...