2015-11-03 128 views
0

嗯,我看过这么多次这个问题,但给TS的所有答案都不适用于我的UserControl。 =(WPF透明用户控件背景

的问题是,当我在用户控件使用背景属性内部设计,它只能如果我将其设置为真正的颜色,像红,蓝,绿等

然而,当我尝试它设置为透明,它又变成了白色。

我有一个窗口,它看起来像这样
enter image description here

什么即时试图实现的,这是
enter image description here

但所有即时得到是这样的(这whiteish背景,还是真的只是透明的任何颜色) enter image description here

如何使人们有可能有什么建议?

P.S.此自定义用户控件是一种MessageBox

更新!忘记(由Ronald Schlenker)提及源代码这种控制 http://www.codeproject.com/Tips/563144/WPF-Dialog-MessageBox-Manager

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(); 
    } 
} 
+0

你可以发布使消息框显示的代码吗? – tgpdyk

+0

@tagaPdyk对不起,忘了提供代码链接,它现在在主线帖子 –

+0

不是。你的代码。看链接,我该如何检查问题?但它的外观,你调用窗口的构造函数内的消息框。这可能是问题所在。 – tgpdyk

回答

1

你的窗口中添加加载的事件,并呼吁TimedCall()那里。你的窗口还没有加载,这就是为什么你想要的背景还没有生效。

+0

gosh,非常感谢你,我完全忘记了Loaded事件,没有用C#编码很长时间 –