سؤال

وأود أن استخدام ملف بابوا نيو غينيا شفافة على زر سلفرليغت. وبالإضافة إلى ذلك أود زر نفسها لتكون شفافة بحيث الخلفية (وراء زر) وتبين من خلال. أجد أنه إذا أنا وضعت التعتيم على زر أنه يؤثر أيضا على صورة. أنا لا أريد الصورة بأكملها لتكون شفافة - مجرد أجزاء شفافة في الأمر على النحو المحدد في PNG

وأي أفكار بشأن كيف يمكن تحقيق ذلك؟

هل كانت مفيدة؟

المحلول

وسيلفرلايت يدعم الشفافية بابوا نيو غينيا. يعمل هذا:

<UserControl x:Class="SilverlightApplication17.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="Green">
<Button Width="200" Height="200">
  <Button.Content>
    <Image Source="http://wildermuth.com/images/tx_head.png" />  
  </Button.Content>
</Button>

ويجب أن تشاهد صورة شفافة إلى الجزء الخلفي من الزر. إذا كنت تريد زر شفافة، ثم YUO تحتاج إلى إنشاء قالب الزر الذي هو واضح. الارتباط في الإجابة texmex5 هو أصل واحد.

نصائح أخرى

ومن تحقيقاتي اللاحقة، يبدو أن ليس كل ملفات PNG شفافة ستعمل. أنها يجب أن تكون شفافة على أساس ألفا (على العكس من لوحة على أساس). عليهم أيضا أن تكون على الأقل 16 بت الصور. معيار 8 بت لا تعمل.

<UserControl x:Class="MyProject.SilverlightControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

        <Grid x:Name="LayoutRoot" Background="Green">
            <Image Width="18" Height="18" DataContext="{Binding PrintMovementCommand}" Source="{Binding IconSource}" VerticalAlignment="Center" HorizontalAlignment="Center" ToolTipService.ToolTip="{Binding Title}" Cursor="Hand">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseLeftButtonUp">
                        <i:InvokeCommandAction Command="{Binding Command}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Image>
        </Grid>

    </UserControl>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top