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

Elementhost and derived WPF class

$
0
0

Hello,

I have a wpf class derived from System.Windows.Controls.Button

-- --- JButtonWPF.cs ---

using System.Windows;
using System.Windows.Controls;

namespace Jedox.Controls
{
    public partial class JButtonWPF : Button
    {
        public JButtonWPF()
        {
            dynamic ds = TryFindResource(ToolBar.ButtonStyleKey);
            if (ds is Style)
            {
                this.Style = ds;
            }
        }
    }
}

( This class has normally more code, but to create my Problem this is sufficient.)

Now I want to host an object of this type in one Windows.Form Dialog.

JButtonWPF Wpfb = new JButtonWPF();

this.btn_user.Child = Wpfb;

this.btn_user.PropertyMap.Remove("BackColor");
this.btn_user.PropertyMap.Remove("BackgroundImage");
this.btn_user.PropertyMap.Remove("BackgroundImageLayout");

When I open the dialog I see a black square, but when I move the mouse over the the button I see a gray  square.

When I comment out the line

this.Style = ds

in JButtonWPF.cs I see  gray square which doesn't Change when I move the mouse over the button, but the button isn't flat anymore.

So how can I achieve that this button has a "flat" style, but doesn't change automagically the Background.

tia

  Hendrik Schmieder


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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