views:

1621

answers:

1

I'm looking for a tutorial that explains creating custom usercontrols in WPF.

I want to have one control that combines a textblock, a textbox, and a button that launches a common fileopen dialog. I have the layout done and everything wired up. It's works but it's three independent controls. Hopefully there is a tutorial out there that explains how to turn this into one usercontrol and wire up everything so I can expose certain properties of the control, like the text in the textbox, to the rest of my WPF app.

A: 

This looks like a good article that might help.

http://www.c-sharpcorner.com/UploadFile/mahesh/WpfUserControl06292008215701PM/WpfUserControl.aspx

In fact, it looks like he's doing exactly what you're trying to do. As for accessing the TextBox contents from outside the user control, create a public property as shown in the article.

public string FileName
{
    get { return FBCTextBox.Text; }
    set { FBCTextBox.Text = value; }
}
Dennis Palmer
Thanks, Dennis! That is exactly what I needed.
Scott