Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
[no name] 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 :)
[no name] 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

If the control is a child of the current control/form, use this.rtbBill.
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900