I saved a picture in sql databse, and i can retrieve and see it in datagrid but i want to do mouse over on picture, tooltip display it more larger (zoom).
This code block has this message in tooltip:Byte[] Array.
<DataGridTemplateColumn Header="Image" Width="45" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<Image Source="{Binding Path=Picture}" Width="100" Height="50" Stretch="Uniform" ToolTip="{Binding Path=Picture}">
</Image>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Add new record event:
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.* ";
dlg.ShowDialog();
FileStream fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read);
byte[] data = new byte[fs.Length];
fs.Read(data, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
System.IO.Stream stream = System.IO.File.Open(dlg.FileName, System.IO.FileMode.Open);
BitmapImage imgsrc = new BitmapImage();
imgsrc.BeginInit();
imgsrc.StreamSource = stream;
imgsrc.EndInit();
this.Picture.Source = imgsrc;
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\programing\WPF\DataBase.mdf;Integrated Security=True;User Instance=True";
con.Open();
SqlCommand sc = new SqlCommand("Insert Into Personnels(No,Name,Family,Picture) Values(@No,@Name,@Family,@Tozihat,@Picture)", con);
sc.Parameters.AddWithValue("@No", txtNo.Text);
sc.Parameters.AddWithValue("@Name", txtName.Text);
sc.Parameters.AddWithValue("@Family", txtFamily.Text);
sc.Parameters.AddWithValue("@Picture", data);
sc.ExecuteNonQuery();
con.Close();
}