3 Replies - 1127 Views - Last Post: 12 July 2011 - 01:52 PM Rate Topic: -----

#1 madmorgan  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 104
  • Joined: 07-May 10

Access WPF Controls via Winform

Posted 12 July 2011 - 12:56 PM

Hello all,

I have a WPF Ribbon control on my main winform. I have a button on the ribbon called "ribbonButtonInternet" with in the ribbon I have created a accessor to it.


        public RibbonButton ViaInternet
        {
            get
            {
                return this.ribbonButtonInternet;
            }
            set
            {
                this.ribbonButtonInternet = value;
            }
        }




and with in the main winform I have this code to access that control.


        private Ribbon MyRibbon;

        public Form1()
        {
            InitializeComponent();
            MyRibbon = new Ribbon();

            MyRibbon.ViaInternet.Click += new System.Windows.RoutedEventHandler(MyRibbon_Click);
        }

        void MyRibbon_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MessageBox.Show("hello");
        }
    }




but when I click the control nothing happens. can somone help solve where I have gone wrong.

Thanks

This post has been edited by madmorgan: 12 July 2011 - 01:03 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Access WPF Controls via Winform

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4531
  • View blog
  • Posts: 7,903
  • Joined: 08-June 10

Re: Access WPF Controls via Winform

Posted 12 July 2011 - 01:30 PM

It's probably because you're creating a new Ribbon, and not using the one that you created in XAML. Of course, since you didn't show the XAML, that's an assumption, but it's a common mistake.

This post has been edited by Curtis Rutland: 12 July 2011 - 01:30 PM

Was This Post Helpful? 0
  • +
  • -

#3 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1012
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Access WPF Controls via Winform

Posted 12 July 2011 - 01:32 PM

I don't see where the ribbon you created is attached to the form.

OT: If it's WPF, it's not Winforms.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Access WPF Controls via Winform

Posted 12 July 2011 - 01:52 PM

This could possibly work..

    public Form1()
    {
        InitializeComponent();

        nameOfRibbonControl.ViaInternet.Click += new System.Windows.RoutedEventHandler(MyRibbon_Click);
    }



Note: I have never tried to load a WPF UserControl into a WinForm app, so I don't even know if this would work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1