0
私はWP7プラットフォームに新しく、奇妙なものに直面しています。イメージを持つカスタムコンポーネントがあります。ここでは(下のカスタムコンポーネントの一部)カスタムコントロールでイメージを読み込む際に問題が発生する
<Rectangle x:Name="ImageForeground" Height="240" Width="240" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{TemplateBinding Foreground}"
DataContext="{TemplateBinding Image}"
OpacityMask="{Binding Converter={StaticResource brushConverter}}" />
がbrushConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
BitmapImage image = (BitmapImage)value;
ImageBrush imageBrush = new ImageBrush();
if (image != null)
{
imageBrush.ImageSource = image;
}
return imageBrush;
}
今私は
<rounded:RoundedImageView Image="/Images/image1.png"/>
でページにカスタムコンポーネントを追加します。ここで奇妙な部分です。このコンポーネントは特定のpng画像のみを表示します!私は5つ全てを持っていて、すべてのBuild ActionプロパティはContentに設定されています。しかし、コントロールは、すべてではなく一部を読み込むだけです。私はそう
<Image Height="200" HorizontalAlignment="Left" Margin="54,17,0,0" Name="image3" Stretch="Fill" VerticalAlignment="Top" Width="200" Source="/Images/service_reload.png" />
それが動作するように、通常の画像コンポーネント内の画像を入れた場合でも、見知らぬ人です! WTF !!
どのようなアイデアですか?
魅力のように働いた: 私はFillプロパティにバインドbrushConverterを添付し HorizontalAlignment = "Center" VerticalAlignment = "Center" DataContext = "Rectangle x:Name =" ImageForeground "は、OpacityMaskプロパティの代わりに、 {TemplateBinding Image} "塗りつぶし=" {バインディングコンバータ= {静的リソースbrushConverter}} " /> ' –
ちょっと不思議です - 画像の代わりに矩形を使用するのはなぜですか? –
@CoolDude - あなたは答えとしてあなたのコメントを投稿し、数日後にそれを受け入れることができます。 – keyboardP