On MainWindow.xaml.cs I defined:
private int _currentStep = 1;
public int CurrentStep
{
get
{
return _currentStep;
}
set
{
_currentStep = value;
NotifyPropertyChanged("CurrentStep");
}
}
private void NotifyPropertyChanged(string info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public event PropertyChangedEventHandler PropertyChanged;
And I'm also update CurrentStep in same file.
On MessageWithProgressBar.xaml I defined:
<Window x:Class="Db.MessageWithProgressBar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Db"
mc:Ignorable="d"
Title="DB Processing" Height="150" Width="300" Background="{DynamicResource {x:Static SystemColors.GradientInactiveCaptionBrushKey}}">
<Window.Resources>
<local:currentStepToProgressValue x:Key="stepToProgress"/>
</Window.Resources>
<Grid DataContext="{Binding RelativeSource={RelativeSource AncestorType=Window}}">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Name="title" Content="Please wait while processing.." FontSize="17.333"/>
</Grid>
<Grid Grid.Row="1" Margin="0,0,0,20">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ProgressBar Name="progress" IsIndeterminate="True" Value="{Binding CurrentStep, Converter={StaticResource stepToProgress}}" />
</Grid>
</Grid>
The error I got on runtime is:
BindingExpression path error: 'CurrentStep' property not found on 'object' ''String' (HashCode=1137317725)'. BindingExpression:Path=CurrentStep; DataItem='String' (HashCode=1137317725); target element is 'ProgressBar' (Name='progress'); target property is 'Value' (type 'Double')
Any assistance?
Thanks!