NotifyCollectionChangedEventHandler command does not work with background worker.Event is as :
void MainWindowsViewModel_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
StrokesEllipse = ((StrokeCollection)sender);
using (var memoryStream = new MemoryStream())
{
StrokesEllipse.Save(memoryStream);
//convert memory stream to array
EllipseDrawing = memoryStream.ToArray();
//save the above array to say - database
}
}
And we declared event on constructor as below
_strokesEllipse = new StrokeCollection();
(_strokesEllipse as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(MainWindowsViewModel_CollectionChanged);
And we are binding stoke collection on the background worker completed event. as Below
string s = GetMechanicSignature();
if (s != "")
{
EllipseDrawing = Convert.FromBase64String(s);
}
if (EllipseDrawing != null)
{
try
{
using (var memoryStream = new MemoryStream(EllipseDrawing))
{
_strokesEllipse = new StrokeCollection(memoryStream);
}
}
catch (Exception)
{
}
inkcanvas control does not showing loaded data. why? When we try without background worker then inkcanvas control loading the data very well? inkcanvas xml is as below
<InkCanvas x:Name="inkCanVas" Grid.Row="0" IsEnabled="{Binding VCRSignatureModel.IsEnable,Mode=TwoWay}" Background="White" Width="700" Height="90" Margin="40,0,0,0" Strokes="{Binding StrokesEllipse,Mode=TwoWay}">
<InkCanvas.DefaultDrawingAttributes>
<DrawingAttributes Color = "Black" Width = "6" />
</InkCanvas.DefaultDrawingAttributes>
</InkCanvas>