I have a WPF application which has a MainWindow which is divided into 2 frames one for the left navigation menu and the other for the pages (like addFirm page , addlocation page etc). Now i want a status bar on the main window which must display messages which are raised in the pages. Something like this
<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" LastChildFill="True" >
<StackPanel DockPanel.Dock="Top" Style="{DynamicResource SMMainStackPanel}" >
<Border Style="{DynamicResource SMBorder}" >
<Label Content="System" FontSize="18" HorizontalContentAlignment="Center" />
</Border>
</StackPanel>
<StackPanel DockPanel.Dock="Left" Style="{DynamicResource SMMainStackPanel}">
<Border VerticalAlignment="Stretch" Style="{DynamicResource SMBorder}" >
<Frame Name="frame1" Source="Menu.xaml" Style="{DynamicResource SMMainFrame}" />
</Border>
</StackPanel>
<StackPanel Style="{DynamicResource SMMainStackPanel}" >
<Border Style="{DynamicResource SMBorder}" >
<Frame Name="frame2" Style="{DynamicResource SMMainFrame}"/>
</Border>
<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" DockPanel.Dock="Bottom">
<StatusBar>
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem>
<TextBlock>Ready</TextBlock>
</StatusBarItem>
<StatusBarItem Grid.Column="1">
<ProgressBar Value="30" Width="80" Height="18"/>
</StatusBarItem>
<StatusBarItem Grid.Column="2">
<TextBlock Text= "ABC" />
</StatusBarItem>
<StatusBarItem Grid.Column="3">
<TextBlock Text="{Binding Source={x:Static sys:DateTime.Now}}"/>
</StatusBarItem>
</StatusBar>
</DockPanel>
</StackPanel>
</DockPanel>
Now i want to populate the StatusBarItem from the message property of the below class instead of the static text "ABC". PS: The obejct of this class is created on the indivisual pages and not on the mainwindow
public class StatusHelper : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _message;
private void OnPropertyChanged(String property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
public string Message
{
get
{
return _message;
}
set
{
_message = value;
OnPropertyChanged("Message");
}
}
}
I create the object of this class on the indivisual pages and then when an operation is completed then how i set the message property of this class.
The only link which i am missing is that how do i get the instance of this class which is set on a page (say suppose on addlocation) on the mainwindow.xaml. Also how do i bind this instance on the text property of the text area.