コントロールページからメインページに画像をバインドしたいのですが、うまくいきません。私はこれを試します:
XAML: <Image Source="{Binding myImage}" Height="150" Name="photoPreview"...
バインディング:
public Image myImage
{
get;
set;
}
ここでいくつかのアイデア?
コントロールページからメインページに画像をバインドしたいのですが、うまくいきません。私はこれを試します:
XAML: <Image Source="{Binding myImage}" Height="150" Name="photoPreview"...
バインディング:
public Image myImage
{
get;
set;
}
ここでいくつかのアイデア?
Image
オブジェクトをSource
Image コントロールのプロパティにバインドすることはできません。Source
プロパティのタイプはですImageSource
。コードで BitmapImage を使用し、代わりにそれをバインドします。
public BitmapImage myImage { get; set; }
または、画像ファイルがプロジェクトのアセットに含まれている場合は、相対パスも (文字列として) バインドできます。
More details from my source maybe someone get idea where is problem>
Control page (POPUP)
private void SaveToIsolatedStorage(Stream imageStream, string fileName)
{
using (IsolatedStorageFile myIsoStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (myIsoStorage.FileExists(fileName))
{
myIsoStorage.DeleteFile(fileName);
}
IsolatedStorageFileStream fileStream = myIsoStorage.CreateFile(fileName);
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(imageStream);
WriteableBitmap mywb = new WriteableBitmap(bitmap);
mywb.SaveJpeg(fileStream, mywb.PixelWidth, mywb.PixelHeight, 0, 95);
fileStream.Close();
}
this.ReadFromIsolatedStorage("myImage.jpg");
}
private void ReadFromIsolatedStorage(string fileName)
{
WriteableBitmap bitmap = new WriteableBitmap(200, 200);
using (IsolatedStorageFile myIsoStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = myIsoStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read))
{
bitmap = PictureDecoder.DecodeJpeg(fileStream);
}
}
photoPreview.Source = bitmap;
}
public String myNote { get; set; }
public String path
{
get;
set;
}
CONTROL PAGE POPUP XAML
<Image Source = "{Binding Path = path}" Height="150" HorizontalAlignment="Right" Name="photoPreview"
New class for binding named Note.cs
public class Note : INotifyPropertyChanged {
public String myNote { get; set; }
public String path
{
get;
set;
}...
Main page
var note = new Note();
note.myNote = control.myNote;
note.OnPropertyChanged("myNote");
note.path = control.path;
note.OnPropertyChanged("path");
Notes.Add(note);
OnPropertyChanged("Notes");
Main page. xaml
<Image Width="100" Height="100" Stretch="Fill" Source = "{Binding Path = path}"></Image>
P.s binding text myNote from textbox work great but image not.
Image
タイプproperty
uを使用する代わりに、このようにinを与えることbind
で直接できます--->image
path
Image
Source
<Image Source = "{Binding Path = path}" Height="150" Name="photoPreview"...
パス (文字列型) u が設定および取得できる場所
public String path
{
get;
set;
}