0

I'm new into WPF and have a problem I can't seem to find a solution for.

I'm writing a G19 (Keyboard) applet. This Keyboard has a 320x240 display attached, which you can access with C#.

I'm using WPF for this, because I don't need to do any GDI drawing anymore and use the normal controls instead.

So. It works as I wish. Everything draws properly except one UserControl. I have downloaded this control -> http://marqueedriproll.codeplex.com/

In the designer, the control works, the Loaded event get's fired and the animation is good. When I run my application, I just see the label and the text. The animation does not work, and the Loaded event does not fire anymore.

Any help is appreciated.

The main function is my wrapper. The wrapper is already a Usercontrol and displays plugins which are switchable. This wrapper has the Frame Control(Wrapper1). I replace the content of this frame every time I switch the plugin.

    public void SetPlugin(IPlugin plugin)
    {
        if (this.MainPlugin != null)
        {
            this.MainPlugin.OnHide();
            ((UserControl)this.MainPlugin).Visibility = System.Windows.Visibility.Hidden; 
        }

        this.MainPlugin = plugin;
        ((UserControl)this.MainPlugin).Visibility = System.Windows.Visibility.Visible;

        this.MainPlugin.OnShow(); 

        this.Wrapper1.Content = this.MainPlugin;
    }

I think it's the right approach to handle a plugin system that way. The plugin get's drawed on my keyboard.

What I don't understand is why the usercontrol only works in the designer view and not in the running application.

The basic code of the scrolling label is so:

    public MarqueeText()
    {
        this.Loaded += new RoutedEventHandler(MarqueeText_Loaded);

        InitializeComponent();
        canMain.Height = this.Height;
        canMain.Width = this.Width;
    }

    void MarqueeText_Loaded(object sender, RoutedEventArgs e)
    {
        StartMarqueeing(_marqueeType);
    }

I don't see a reason why it doesn't work. Actually Ive always found a way to fix a problem but this time I see nothing.

Thanks in advance. Your help is really required today. Have a great saturday! :)

Damir Arh
  • 17,637
  • 2
  • 45
  • 83
Moe
  • 43
  • 3

1 Answers1

0

I am guessing you are rendering to a bitmap target, rather than onscreen. If you are using RenderTargetBitmap, you have a couple of responsibilities. You need to set both a presentation source, and make sure you run events on the dispatcher.

Normally, App.xaml or Application.Run does this for you, but if you are not using a Window, you are on your own.

See this related question for details.

Community
  • 1
  • 1
Mitch
  • 21,223
  • 6
  • 63
  • 86