This question is locked. New answers and comments are not allowed.
3/20/2012:
I have a need to programmatically build out a RadRichTextBox.
I've been scrounging the documentation and examples and finally got stuck building out a table.
I'm trying to set the style of a single cell to bold, and it was driving me crazy, then I found the post that had the example "CodeBehindDocument.zip" attached.
I jumped in and started using that code and still had problems, so I thought I'd try to run the example and got the same error there.
on the very first Span Style instantiation, it throws an exception:
and the exception is
System.InvalidOperationException:UnsupportedStyle type for Span: Unknown
the 'Unknown' part made me possibly think it was the fact that the constructor is empty, so I tried this:
but that gave me the same error on the sp00.Style= line
Any assistance on this would be great.
I'm running 2011 Q3 SP1
Thanks!
-Dave
3/21/2012:
I seem to have gotten a bit farther, but am still having problems.
I'm trying to use code from your WPF sample to see if I can make it work in Silverlight 4:
http://www.telerik.com/help/wpf/radrichtextbox-features-document-elements-tables.html#Creating_a_Table_Programatically_at_runtime
I'm looking at that page because I can't find a similar one for Silverlight.
I can get all the way through the table setup including some styles, but it throws an exception on adding the section to the document.
If I leave out the styling, I can add it.
Here's the code that sets up the section and calls the method to build the table:
The BuildTable method looks like this:
As shown, it will run fine, but the table font is large and not of my selection, and both cells are normal font weight. If I enable either of the two commented sections in the code above, I get a clean compile, the method returns fine, but the sections.Add in the calling block of code throws an exception:
+ _exception {System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at System.Collections.Generic.ExtensionMethods.GetValueOrNull[TKey,TValue](IDictionary`2 dict, TKey key)
at Telerik.Windows.Documents.Model.StyleCollection.EnsureStyleRegistered(StyleDefinition styleDefinition)
at Telerik.Windows.Documents.Model.RadDocument.EnsureElementStyleInDocument(IElementWithStyle documentElement)
at Telerik.Windows.Documents.Model.RadDocument.CheckForNotRegisteredStyles(DocumentElement documentElement)
Putting the table up and not being able to format cells isn't useful, and I can't find documentation on this.
If you can point me to the documentation or a sample that runs, I'd certainly be appreciative.
Thanks!
-Dave
I have a need to programmatically build out a RadRichTextBox.
I've been scrounging the documentation and examples and finally got stuck building out a table.
I'm trying to set the style of a single cell to bold, and it was driving me crazy, then I found the post that had the example "CodeBehindDocument.zip" attached.
I jumped in and started using that code and still had problems, so I thought I'd try to run the example and got the same error there.
on the very first Span Style instantiation, it throws an exception:
sp00.Style = new StyleDefinition();
and the exception is
System.InvalidOperationException:UnsupportedStyle type for Span: Unknown
the 'Unknown' part made me possibly think it was the fact that the constructor is empty, so I tried this:
StyleDefinition sd = new StyleDefinition();
sd.SetPropertyValue(Span.FontWeightProperty, FontWeights.Bold);
Span sp00 = new Span("Cell 00");
sp00.Style = new StyleDefinition(sd);
but that gave me the same error on the sp00.Style= line
Any assistance on this would be great.
I'm running 2011 Q3 SP1
Thanks!
-Dave
3/21/2012:
I seem to have gotten a bit farther, but am still having problems.
I'm trying to use code from your WPF sample to see if I can make it work in Silverlight 4:
http://www.telerik.com/help/wpf/radrichtextbox-features-document-elements-tables.html#Creating_a_Table_Programatically_at_runtime
I'm looking at that page because I can't find a similar one for Silverlight.
I can get all the way through the table setup including some styles, but it throws an exception on adding the section to the document.
If I leave out the styling, I can add it.
Here's the code that sets up the section and calls the method to build the table:
Section section0 = new Section();
Table TopTable = BuildTable();
section0.Blocks.Add(TopTable);
RichTextPrint.Document.Sections.Add(section0);
The BuildTable method looks like this:
private Table BuildTable()
{
Table table = new Table(); // 2 rows, 3 columns
table.Borders.All = new Telerik.Windows.Documents.Model.Border(BorderStyle.None);
//table.Style = new StyleDefinition(StyleType.Table);
//table.Style.SpanProperties.FontFamily = new FontFamily("Tahoma");
//table.Style.SpanProperties.FontSize = Unit.PointToDip(10);
TableRow row0 = new TableRow();
TableCell cell00 = new TableCell();
cell00.PreferredWidth = new TableWidthUnit(150);
Paragraph p00 = new Paragraph();
Span s00 = new Span("Caption:");
p00.Inlines.Add(s00);
//p00.Style = new StyleDefinition(StyleType.Paragraph);
//p00.Style.SpanProperties.FontWeight = FontWeights.Bold;
cell00.Blocks.Add(p00);
row0.Cells.Add(cell00);
TableCell cell01 = new TableCell();
Paragraph p01 = new Paragraph();
Span s01 = new Span("Value");
p01.Inlines.Add(s01);
cell01.Blocks.Add(p01);
row0.Cells.Add(cell01);
table.Rows.Add(row0);
return table;
}
As shown, it will run fine, but the table font is large and not of my selection, and both cells are normal font weight. If I enable either of the two commented sections in the code above, I get a clean compile, the method returns fine, but the sections.Add in the calling block of code throws an exception:
+ _exception {System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at System.Collections.Generic.ExtensionMethods.GetValueOrNull[TKey,TValue](IDictionary`2 dict, TKey key)
at Telerik.Windows.Documents.Model.StyleCollection.EnsureStyleRegistered(StyleDefinition styleDefinition)
at Telerik.Windows.Documents.Model.RadDocument.EnsureElementStyleInDocument(IElementWithStyle documentElement)
at Telerik.Windows.Documents.Model.RadDocument.CheckForNotRegisteredStyles(DocumentElement documentElement)
Putting the table up and not being able to format cells isn't useful, and I can't find documentation on this.
If you can point me to the documentation or a sample that runs, I'd certainly be appreciative.
Thanks!
-Dave