0

I can't figure out why, but my modal window turned blurry. Have no idea of what is causing this and it's frustrating me at this point. I did not notice this (which i suppose i would have) at any time when working on it, and suddenly i was like, what in the name of god is this...

What is suprising is that it only happens in the modal, and not in the main window, so it must be something i changed. I've already checked i don't have a blurry effect on just in case i activated it unintendedly, and can't figure out what else can be causing this. The only effect i applied was a dropShadow, as you can see in the images.

Here is a picture of what it's looking like: blurry modal

The quality of the picture doesnt seem to be good enough, but you can see anyway how the modal is much more blurry than the background (which is the main window).

As you can see in this other picture, in the design window it's not showing blurry, just in case this might help. not blurry in design window

any idea of what might have caused this? thx

EDIT: By the way, the content you see in the first image, which is not in the design window, is put there programatically.

<Window x:Class="CholaYTD.WpfMBFin"
    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:local="clr-namespace:CholaYTD"
    mc:Ignorable="d"
    Title="WpfMBFin" Height="275" Width="400" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="{x:Null}" Foreground="#FFEBF3FA" AllowsTransparency="True" SnapsToDevicePixels="True">
<Border BorderThickness="1" BorderBrush="#000000" CornerRadius="25" Background="#2F3138" VerticalAlignment="Center" HorizontalAlignment="Center" >
    <Border.Effect>
        <DropShadowEffect Opacity="0.8"/>
    </Border.Effect>
    <DockPanel MinWidth="375" MinHeight="100" Height="250" HorizontalAlignment="Center" VerticalAlignment="Top">
        <StackPanel DockPanel.Dock="Top"  HorizontalAlignment="Center" VerticalAlignment="Top" >
            <!-- Titulo -->
            <Label Content="DESCARGAS FINALIZADAS" HorizontalAlignment="Center" Margin="0 15 0 0" Foreground="#FFEBF3FA" FontFamily="Berlin Sans FB"
                   FontSize="20" />
            <!-- Descripcion -->
            <Label Content="Las descargas finalizaron con éxito." HorizontalAlignment="Center" Margin="0 5 0 0" Foreground="#FFEBF3FA" 
                   FontFamily="Berlin Sans FB" FontSize="16" />
            <!-- Descripcion fallidas -->
            <!--<Label Content="Las descargas finalizaron con éxito." HorizontalAlignment="Center" Margin="0 0 0 0" 
                   Foreground="#FFEBF3FA" FontFamily="Berlin Sans FB" FontSize="16" />-->
            <!-- Enlaces -->
            <TextBlock Name="textBox_enlaces" HorizontalAlignment="Center" Margin="0 0 0 0" Foreground="#FFEBF3FA" FontFamily="Berlin Sans FB" FontSize="16" >

            </TextBlock>
        </StackPanel>
        <!-- Boton OK -->
        <StackPanel Name="stackPanelCerrar" DockPanel.Dock="Bottom" Height="35" Width="60" VerticalAlignment="Bottom" Margin="0 0 0 10">
            <Border Name="borderCerrar" BorderThickness="1" BorderBrush="#000000" CornerRadius="15" Background="#9FBED1" MouseDown="Border_MouseDown" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave" Cursor="Hand" >
                <Label Name="labelCerrar" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontFamily="Berlin Sans FB" FontSize="20" Foreground="#2F3138" >
                    OK
                </Label>
            </Border>
        </StackPanel>        
    </DockPanel>
</Border>    

public partial class WpfMBFin : Window
{
    private List<string> listaEnlaces;

    public WpfMBFin(List<string> failedList)
    {
        listaEnlaces = failedList;

        InitializeComponent();
        // declaramos la venata principal como padre de esta ventana
        this.Owner = App.Current.MainWindow;

        crearEnlaces();
    }

    private void crearEnlaces()
    {
        string youtubeURLStarting = "https://www.youtube.com/watch?v=";
        string textoFinalEnlaces = "Sin embargo, ";
        if (listaEnlaces.Count < 2)
        {
            textoFinalEnlaces += "el siguiente video no estaba disponible:\n";
            Hyperlink hLink = new Hyperlink();
            hLink.NavigateUri = new Uri(youtubeURLStarting + listaEnlaces.ElementAt(0));
            hLink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(Hyperlink_RequestNavigate);
            hLink.Inlines.Add(youtubeURLStarting + listaEnlaces.ElementAt(0));
            textBox_enlaces.Inlines.Add(textoFinalEnlaces);
            textBox_enlaces.Inlines.Add(hLink);

        }
        else
        {
            textoFinalEnlaces += "los siguientes videos no estaban disponibles:\n";
            foreach (string link in listaEnlaces)
            {
                textoFinalEnlaces += "\n" + youtubeURLStarting + link;
            }
        }            
    }

    // HANDLER de Hyperlinks
    private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
    {
        System.Diagnostics.Process.Start(e.Uri.AbsoluteUri);
    }

    // EFECTO BOTON
    private void Border_MouseDown(object sender, MouseButtonEventArgs e)
    {
        this.Close();
    }

    private void Border_MouseEnter(object sender, MouseEventArgs e)
    {
        stackPanelCerrar.Height = 36;
        stackPanelCerrar.Width = 62;

        borderCerrar.BorderBrush = (Brush)(new BrushConverter().ConvertFrom("#EBF3FA"));
        borderCerrar.BorderThickness = (new Thickness(2, 2, 2, 2));
        borderCerrar.Background = (Brush)(new BrushConverter().ConvertFrom("#EBF3FA"));

        labelCerrar.Foreground = (Brush)(new BrushConverter().ConvertFrom("#2F3138"));
    }

    private void Border_MouseLeave(object sender, MouseEventArgs e)
    {
        stackPanelCerrar.Height = 35;
        stackPanelCerrar.Width = 60;

        borderCerrar.BorderBrush = Brushes.Black;
        borderCerrar.BorderThickness = (new Thickness(1, 1, 1, 1));
        borderCerrar.Background = (Brush)(new BrushConverter().ConvertFrom("#9FBED1"));

        labelCerrar.Foreground = (Brush)(new BrushConverter().ConvertFrom("#2F3138"));
    }
}
  • 1
    It looks like your modal is suffering from pixel approximation, try setting `SnapsToDevicePixels` and/or `UseLayoutRounding` on your modal to `true`. Also, if the content of your modal is centered horizontally/vertically, try to ensure that the parity of the modal and its content width/height is the same, i.e. if the modal is of even (odd) width, its content is of corresponding (even/odd) width. Same goes to height. – Grx70 Jun 23 '18 at 23:34
  • UseLayoutRounding worked like a charm. Thank you very much! what are those 2 options? should i always use them? – TheBandolero Jun 24 '18 at 03:48
  • [Here's](https://stackoverflow.com/questions/2399731/when-should-i-use-snapstodevicepixels-in-wpf-4-0) a good explanation of what's what. – Grx70 Jun 24 '18 at 07:25

0 Answers0