Пример #1
0
        private void employeesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Get the currently selected employee.
            currentEmployee =
                (Employees)this.employeesComboBox.SelectedItem;

            try
            {
                //<snippetGetReadStreamClient>
                // Get the read stream for the Media Resource of the currently selected
                // entity (Media Link Entry).
                using (DataServiceStreamResponse response =
                           context.GetReadStream(currentEmployee, "image/bmp"))
                {
                    // Use the returned binary stream to create a bitmap image that is
                    // the source of the image control.
                    employeeImage.Source = CreateBitmapFromStream(response.Stream);
                }
                //</snippetGetReadStreamClient>

                //<snippetGetReadStreamClientUri>
                // Get the read stream URI for the Media Resource of the currently selected
                // entity (Media Link Entry), and use it to create a bitmap image that is
                // the source of the image control.
                employeeImage.Source = new BitmapImage(context.GetReadStreamUri(currentEmployee));
                //</snippetGetReadStreamClientUri>
            }
            catch (DataServiceRequestException ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }
        }