darki73
darki73

Reputation: 1127

WPF Transparent UserControl Background

Well, i saw this question so many times, but all the answers given to TS are not applicable to my UserControl. =(

The problem is, when i use Background property on UserControl inside Designer, it works only if i set it to real color, like Red, Blue, Green, etc.

However, when i try to set it to Transparent, it again becomes white.

I have a window which looks like this
enter image description here

What im trying to achieve, is this
enter image description here

But all im getting is this (this whiteish background, or really any color except transparent) enter image description here

Any suggestions on how to make it possible?

P.S. This custom user control is a kind of a MessageBox

Update! Forgot to mention source code for this control http://www.codeproject.com/Tips/563144/WPF-Dialog-MessageBox-Manager (by Ronald Schlenker)

public partial class LoginWindow : Window
{
    public LoginWindow()
    {
        InitializeComponent();
        string languageCode = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
        string Path = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
        TimedCall();
    }

    private void TimedCall()
    {
        System.Threading.Timer timer = null;
        timer = new System.Threading.Timer((obj) =>
        {
            ShowMessageBox();
            timer.Dispose();
        },
                    null, 3000, System.Threading.Timeout.Infinite);
    }

    private void ShowMessageBox()
    {
        var _dialogManager = new DialogManager(this, Dispatcher);
        _dialogManager
        .CreateMessageDialog("Test", "I'm a dialogafsaffsfsf", DialogMode.Ok)
        .Show();  
    }
}

Upvotes: 0

Views: 1009

Answers (1)

tgpdyk
tgpdyk

Reputation: 1233

Add a Loaded event on your Window and call TimedCall() there. Your window is not loaded yet, that is why the background you desire is not taking in effect yet.

Upvotes: 1

Related Questions