Click here to Skip to main content
14,334,965 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello community,

I created a xaml-control inside a windows form.
In my XAML.cs file I want to get access to a rich textbox inside this form. I declared it public but i cant get access to it...

thx in advance

What I have tried:

public System.Windows.Forms.RichTextBox rtbBill;

private void btnBill_Click(object sender, RoutedEventArgs e)
        {
            // get access to rtbCuisine here
        }
Posted
Updated 4-Jan-17 3:38am
Comments
NotPolitcallyCorrect 4-Jan-17 9:30am
   
Well.... the name of the control is rtbBill not rtbCuisine to begin with.
Member 11964326 4-Jan-17 13:23pm
   
thx for this helpful answer :)
NotPolitcallyCorrect 4-Jan-17 14:55pm
   
You're welcome, I suppose. Nothing else in your posting makes any sense.
Jon McKee 4-Jan-17 13:59pm
   
I don't have tons of experience with WinForms but I'm guessing you're using an ElementHost to host a WPF UserControl or similar? You may have to traverse the hierarchy using ElementHost.Parent. It would really help to have more of the code. What you've posted doesn't show anything relevant such as the code which hosts the xaml or the xaml itself so I doubt you'll get any meaningful responses.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

If the control is a child of the current control/form, use this.rtbBill.
   
v2
Comments
Member 11964326 4-Jan-17 13:24pm
   
that does not work, cause the rich textbox is on the form and the button on the xaml file...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100