Hi all,
Got any issue with xamarin form, am using prism framework, and got have a tabbed page with 3 tabs, first tab using zxing control to scan barcode.
The problem is that, everytime the tab page load (any tab), the camera seems to be active. I have already implemented IActiveAware, under isactive then will set isscanning and isanalyzing to true, but seems like even I am not in the scan tab page, the camera module still active.
Any help is welcome, thanks
Code below:
ViewModel:
private bool _isAnalyzing = false;
public bool IsAnalyzing
{
get
{
return _isAnalyzing;
}
set
{
if (SetProperty(ref _isAnalyzing, value))
{
//Do something
}
}
}
private bool _isScanning = false;
public bool IsScanning
{
get
{
return _isScanning;
}
set
{
if (SetProperty(ref _isScanning, value))
{
}
}
}
private bool _isActive;
public bool IsActive
{
get { return _isActive; }
set { SetProperty(ref _isActive, value, RaiseIsActiveChanged); }
}
protected virtual void RaiseIsActiveChanged()
{
IsActiveChanged?.Invoke(this, EventArgs.Empty);
if (IsActive)
{
IsScanning = true;
IsAnalyzing = true;
//_isAnalyzing = true;
//RaisePropertyChanged("IsAnalyzing");
}
else
{
IsScanning = false;
IsAnalyzing = false;
}
}
xmal:
<zxing:ZXingScannerView x:Name="scanView" IsScanning="{Binding IsScanning}"
IsAnalyzing="{Binding IsAnalyzing}"
Result="{Binding Result, Mode=TwoWay}"
ScanResultCommand="{Binding OnScannedCommand}"
VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" />
<zxing:ZXingDefaultOverlay x:Name="scanOverlay"
TopText="Place the red line over the barcode"
ShowFlashButton="False"
Opacity="0.9" />