Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Attaching a style in a custom Control

$
0
0

I am working on my first custom control.  It uses a RichTextBox with inline TextBox controls.  I am planning to modify the FlowDocument to contain a series of InlineUIContainers interspersed throughout the FlowDocument Text.  The InlineUIContainers will contain TextBox UIElements.  Currently, I am planning to create the whole RichTextBox Document in code.  For the TextBox UIElement, I would like to specify a style that is defined in the Generic.xml file of the custom Control class library.  The code would look something like:

Paragraph p = new paragraph();
InlineUIContainer uic = new InlineUIContainer();
TextBox tb=new TextBox();
tb.Style = How do I do this?
tb.Text = "etc";
tb.Tag = "something";
uic.Child=tb;
p.Inlines.Add(uic);

Questions:
1.  How do I attach the style in the generic.xml file to the tb Element?
2.  Is there a way to use a DataTemplate for the InLineUIContainer instead of doing the above in code? and how would I add it to the paragraph?

Thanks very much for any suggestions.


Robotuner


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>