我正在使用XamlCropControl库here。我无法将图像从StorageFile绑定到裁剪控件。 对于XamlCropControl,他们喜欢这样:
<xamlcrop:CropControl x:Name="Crop" ImageSource="ms-appx:///Assets/wrench.jpg" DesiredAspectRatio="1.0" />
但在我的情况下,我需要绑定从图库中挑选的图像,然后将其传递给裁剪控件。我确实喜欢吼叫,但它根本不起作用。
public async void ImageReceiver(StorageFile image)
{
BitmapImage bitmapImage = new BitmapImage();
FileRandomAccessStream stream = (FileRandomAccessStream)await image.OpenAsync(FileAccessMode.Read);
bitmapImage.SetSource(stream);
ImgParam = bitmapImage;
}
private BitmapImage imgParam;
public WriteableBitmap ImgParam
{
get { return imgParam; }
set
{
imgParam = value;
RaisePropertyChanged("ImgParam");
}
}
在xaml文件中:
<xamlcrop:CropControl x:Name="CropControl"
ImageSource="{Binding ImgParam, Mode=TwoWay}"
DesiredAspectRatio="1.0"
Background="Black"
Width="100"
Height="100"/>