Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

When transparent is not transparent for a control

$
0
0

I have a problem with background.  I have a UserControl which is hosted in a popup which is hosted by a Window with the following attributes:

        Background="Transparent"  
        AllowsTransparency="True" 
        WindowStyle="None" 
        WindowStartupLocation="CenterScreen" 

Now in the VS 2010 designer the control (just showing the part that is wrong) shows the following:

As you can see the upper left corner shows white which because the designer itself has a white background is actually transparent.  If I change the color to Red it will show as Red.

Now when I execute the application this little section shows as Black.  Using Snoop I confirmed that the Grid (XAML to come later) is what shows as black but  when I snooped the Background property it showed as #00FFFFFF and local.  Again if I execute the app with the background set to Red it shows Red when executing.

UserControl XAML:

<UserControl x:Class="ArtistSearchUC"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:NewMediaPlayer"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Background="Transparent"  
             MouseLeftButtonDown="Window_MouseLeftButtonDown"
             Height="500" Width="800" Loaded="UserControl_Loaded" PreviewKeyDown="artistGrid_PreviewKeyDown" Foreground="{x:Null}"><UserControl.Resources><local:ArtistNameVisibilty x:Key="anv"></local:ArtistNameVisibilty><local:FontConverter x:Key="fontSiz"></local:FontConverter><Style x:Key="NoButtonBorder" TargetType="{x:Type Button}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><ContentPresenter                  
                            Margin="{TemplateBinding Padding}"                  
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"                  
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"                  
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"                  
                            ContentTemplate="{TemplateBinding ContentTemplate}"                  
                            RecognizesAccessKey="True"                  
                            Content="{TemplateBinding Content}" /></ControlTemplate></Setter.Value></Setter></Style></UserControl.Resources><Border CornerRadius="30"><Grid x:Name="theTopGrid" Background="Transparent"><Grid.RowDefinitions><RowDefinition Height="40"></RowDefinition><RowDefinition Height="*"></RowDefinition></Grid.RowDefinitions><TextBlock Text="Artist Search" Foreground="Beige" FontSize="30" HorizontalAlignment="Center" ></TextBlock><Grid x:Name="artistGrid" Focusable="True" Background="Transparent" Grid.Row="1"><Grid.RowDefinitions><RowDefinition Height="50"></RowDefinition><RowDefinition Height="*"></RowDefinition></Grid.RowDefinitions><StackPanel Orientation="Horizontal" Grid.Row="0" ><TextBlock Text="{Binding ArtistFirstChar}" Grid.Row="0" Foreground="Beige" FontSize="48" FontFamily="Algerian"></TextBlock><ComboBox x:Name="GList" ItemsSource="{Binding GenreList}" Height="30" Width="100" Margin="20,0,0,0"
                                      SelectedIndex="0" SelectionChanged="ComboBox_SelectionChanged" Focusable="False" ></ComboBox></StackPanel><ListBox x:Name="artistNames" VerticalAlignment="Top" Grid.Row="1"
                                    Background="Transparent" BorderThickness="0"
                                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"  
                                    ScrollViewer.VerticalScrollBarVisibility="Auto"><ListBox.ItemsPanel><ItemsPanelTemplate><WrapPanel Orientation="Horizontal"/></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemTemplate><DataTemplate><Button x:Name="artistButton" Style="{StaticResource NoButtonBorder}" Content="{Binding}" Margin="0,0,12,8" Foreground="Beige" 
                                    HorizontalContentAlignment="Center" VerticalContentAlignment="Center" 
                                        Click="artistButton_Click"
                                        Visibility="{Binding Converter={StaticResource anv}}"
                                        FontSize="{Binding Converter={StaticResource fontSiz}}" ></Button></DataTemplate></ListBox.ItemTemplate></ListBox></Grid></Grid><Border.Background><RadialGradientBrush><GradientStop Color="#FF32D197" Offset="0" /><GradientStop Color="#FF1B5216" Offset="1" /></RadialGradientBrush></Border.Background></Border></UserControl>

Image of black when executing:

Checking my XAML (and I don't set colors in code) there is nowhere that I set the Background to Black so I am stuck at this time.

TIA


Lloyd Sheen


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>