Windows Phone 8.1 文本框
Windows Phone 8.1 TextBox
我想从我的 windows phone 中获取图像到文本框或 Rich TextBlock 中。由于 Rich TextBox 在 windows phone 8.1 中不受支持。所以问题是 Rich TextBlock 不允许获取用户输入。因为我只想在同一个文本框中获取用户输入和图像。
谢谢
您可以在堆栈面板中设置您的 texblock 并将您的图像设置为背景。这是一个例子
<StackPanel >
<StackPanel.Background>
<ImageBrush ImageSource="/Assets/image.png"></ImageBrush>
</StackPanel.Background>
<TextBox x:Name="email"
/>
</StackPanel>
<StackPanel Name="Stack_image" >
<StackPanel.Background>
<ImageBrush ImageSource="{Binding}"></ImageBrush>
</StackPanel.Background>
<TextBox x:Name="email" />
</StackPanel>
后面的代码:
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// a file to save a photo
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(
"Photo.jpg", CreationCollisionOption.ReplaceExisting);
await takePhotoManager.CapturePhotoToStorageFileAsync(imgFormat, file);
IRandomAccessStream filestream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
BitmapImage imagetobind = new BitmapImage();
imagetobind.SetSource(filestream);
Stack_image.DataContext = imagetobind;
我想从我的 windows phone 中获取图像到文本框或 Rich TextBlock 中。由于 Rich TextBox 在 windows phone 8.1 中不受支持。所以问题是 Rich TextBlock 不允许获取用户输入。因为我只想在同一个文本框中获取用户输入和图像。 谢谢
您可以在堆栈面板中设置您的 texblock 并将您的图像设置为背景。这是一个例子
<StackPanel >
<StackPanel.Background>
<ImageBrush ImageSource="/Assets/image.png"></ImageBrush>
</StackPanel.Background>
<TextBox x:Name="email"
/>
</StackPanel>
<StackPanel Name="Stack_image" >
<StackPanel.Background>
<ImageBrush ImageSource="{Binding}"></ImageBrush>
</StackPanel.Background>
<TextBox x:Name="email" />
</StackPanel>
后面的代码:
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// a file to save a photo
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(
"Photo.jpg", CreationCollisionOption.ReplaceExisting);
await takePhotoManager.CapturePhotoToStorageFileAsync(imgFormat, file);
IRandomAccessStream filestream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
BitmapImage imagetobind = new BitmapImage();
imagetobind.SetSource(filestream);
Stack_image.DataContext = imagetobind;