Telerik Forums
UI for WPF Forum
1 answer
21 views

Hey Telerik Team,

I'm working with the RadRichTextEditor in WPF and ran into a little issue. When I switch my keyboard to Arabic, I was expecting to see Arabic digits (٠١٢٣٤٥), but instead, it still shows the standard Western numbers.

Is there a way to enable Arabic digits when typing in Arabic? I’ve looked around but haven’t had much luck so far. If there's a setting or a workaround that could help, I’d really appreciate any pointers!


using System.Globalization;

Console.OutputEncoding = System.Text.Encoding.UTF8;

CultureInfo arabicCulture = new CultureInfo("ar-AE");
arabicCulture.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
arabicCulture.NumberFormat.NativeDigits = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"];
//arabicCulture.CultureTypes = CultureTypes.
Thread.CurrentThread.CurrentCulture = arabicCulture;
Thread.CurrentThread.CurrentUICulture = arabicCulture;


int number = 12345;
Console.WriteLine(number.ToString(CultureInfo.CurrentCulture));

Stenly
Telerik team
 answered on 20 Mar 2025
1 answer
21 views

Hi,

In my project I am working on using RichTextBox to edit HTML text. In the project I use implicit styling and the Expression Dark theme. And for everything else in the project it works fine, but I am having issues with the RichTextBox.

I have added the reference to the dll, and in App.xaml I have added the styles. I was expecting the textbox to become darker, but I can also see a bunch of errors from the styling.

Wonder what I am missing.

 

Martin Ivanov
Telerik team
 answered on 27 Feb 2025
0 answers
39 views

 

Hello,

I have found a bug in the Track Changes Mode. It also occurs in the latest version (in the demo). To reproduce the bug:

  1. Enable Track Changes mode.
  2. Insert some text, e.g., "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
  3. Wait for a short period (to allow the insertion to occur at different times), approximately 10-15 seconds.
  4. After inserting a word entire the existing text (like on the screenshot), type a character or word, then immediately try to delete the last character using the backspace key. At this point, the error occurs: backspace does not remove the last character, only on the second attempt.

 

 

 

The error occurs in Telerik WPF 2022.1.222, but in the new version, it still appears, though without throwing exceptions (I checked in the lastest demo, and the last character doesn't delete on the first attempt).

Can you reproduce this issue, or is it a known problem?

Is there a solution available?

 

Emin Sadigov
Top achievements
Rank 2
Iron
Iron
Iron
 updated question on 21 Jan 2025
1 answer
76 views

I have a new WPF application, one that I am updating from Framework to Core.   Everything has been converted and working properly except for one thing: the CheckBoxControl controls are not displaying.  All other controls, including things like RadButton are RadGridView, are all displaying and working perfectly.    I deleted the BIN and OBJ folders and cleaned the project, no change.   

If I change the code to use the standard WPF CheckBox control everything works correctly.

The main project of the solution has this inside it's project file:

    <PackageReference Include="Telerik.UI.for.Wpf.80.Xaml" Version="2024.4.1213" />
    <PackageReference Include="Telerik.Windows.Themes.Crystal.for.Wpf" Version="2024.4.1213" />

I have other projects in the solution that have working Telerik controls (except for the CheckBoxControl) that contain this in their project files:

    <PackageReference Include="Telerik.UI.for.Wpf.80.Xaml" Version="2024.4.1213" />

in the xaml form:

<telerik:CheckBoxControl Grid.Row="5" Grid.Column="0" Name="ChkCustomProcess"  HorizontalAlignment="Right" VerticalAlignment="Center"  Margin="5" />

// I have tried this with and without binding to the IsChecked property.

Everything else works fine, including the theming, except for the invisible CheckBox Control.   IntelliSense works in the editor; no compilation errors or warnings.

I am using the NuGet packages from Telerik.  There are no pending updates. I am not referencing any NoXaml packages.

It's probably something simple I am missing. Any thoughts and ideas would be greatly appreciated.

Thanks,
Lou

Martin Ivanov
Telerik team
 answered on 13 Jan 2025
0 answers
44 views

I would like to drag text outside of a WPF RadRichTextBox into a different App.

It seems that dragging any text just outside of this control is not possible, not even within the same app.
IMHO the problem is, that text can be moved within this control, and this feature cannot be deactivated.

Thanks a lot in advance for any hints.

Edit: Just checked with standard RichTextBox (FlowControl) no problems out of the box. I can drag text internal and as soon as mousepointer went outside, everything is fine and works there.  Try this with RadRichTextBox and the Prompt goes crazy inside of your control.

 

 




Marcus
Top achievements
Rank 2
 updated question on 06 Dec 2024
2 answers
39 views
Hi every one,

I've read the documentation about RadSpellChecker and couldn't find anything to do with RadSyntaxEditor. I've already implemented a spellchecker inspiring WordSpellChecker class from SDK Sample Browser and linked it to the RadSyntaxControl via a tagger although I'm not sure if it's a best practice. This solution has a couple of issues including having a lag as a result of working with document in WordSpellChecker and also it needs to be implemented everything from scratch like managing the dictionary.

Does anyone have any better idea or is there any smooth way to join them?

Thanks,
Dariush
Dariush
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 04 Nov 2024
1 answer
45 views

Hi,

We are getting an exception when trying to set the CaretPosition in a RadDocument.

The Document is created in code:


        public void PurchaseTemplate()
        {
            try
            {
                RadDocumentEditor editor = new RadDocumentEditor(doc_text.Document);
                string[] rowName = new string[] { "Make", "Model", "Technical Spec.", "Order No.", "Date Ordered", "Date Delivered", "Price", "Payment Method", "Supplier", "Tel.", "Other Details", "Manufacturer", "Tel.", "Other Details", "Guarantee", "Period", "Expiry Date", "Notes" };

                TableWidthUnit w1 = new TableWidthUnit(180);    // Date
                TableWidthUnit w2 = new TableWidthUnit(500);    // Day

                TableCell cell1 = new TableCell();
                TableCell cell2 = new TableCell();

                TableRow row = new TableRow();
                Paragraph p1 = new Paragraph();
                Span s1 = new Span();
                string subject = " ";
                if (_selelement != null)
                {
                    subject = _selelement.GetAttribute("title");
                }


                Table table = new Table();
                table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;
                table.Tag = "5000";
                table.Rows.ElementAdded += doc_text_DiaryChanged;

                cell1.Background = Color.FromRgb(242, 219, 219);
                cell1.PreferredWidth = w1;
                cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                s1.FontWeight = FontWeights.Bold;
                s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s1.Text = "Item";
                p1.Inlines.Add(s1);
                cell1.Blocks.Add(p1);

                p1 = new Paragraph();
                s1 = new Span();
                cell2.Background = Color.FromRgb(242, 219, 219);
                cell2.PreferredWidth = w2;
                cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                s1.FontWeight = FontWeights.Bold;
                s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s1.Text = subject;
                p1.Inlines.Add(s1);
                cell2.Blocks.Add(p1);

                row.Cells.Add(cell1);
                row.Cells.Add(cell2);
                table.Rows.Add(row);
                int nRow = 0;
                foreach (string name in rowName)
                {
                    row = new TableRow();
                    cell1 = new TableCell();
                    cell2 = new TableCell();
                    switch (nRow)
                    {
                        default:
                            p1 = new Paragraph();
                            s1 = new Span();
                            cell1.Background = Color.FromRgb(255, 255, 255);
                            cell1.PreferredWidth = w1;
                            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontWeight = FontWeights.Bold;
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = name;
                            p1.Inlines.Add(s1);
                            cell1.Blocks.Add(p1);

                            p1 = new Paragraph();
                            s1 = new Span();
                            cell2.Background = Color.FromRgb(255, 255, 255);
                            cell2.PreferredWidth = w2;
                            cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = " ";
                            p1.Inlines.Add(s1);
                            cell2.Blocks.Add(p1);

                            row.Cells.Add(cell1);
                            row.Cells.Add(cell2);
                            table.Rows.Add(row);
                            break;
                        case 9:
                        case 10:
                        case 12:
                        case 13:
                        case 15:
                        case 16:
                            DocumentList bullets = new DocumentList(DefaultListStyles.Bulleted, doc_text.Document);
                            p1 = new Paragraph();
                            s1 = new Span();
                            cell1.Background = Color.FromRgb(255, 255, 255);
                            cell1.PreferredWidth = w1;
                            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = name;
                            p1.Inlines.Add(s1);
                            bullets.AddParagraph(p1);
                            cell1.Blocks.Add(p1);

                            p1 = new Paragraph();
                            s1 = new Span();
                            cell2.Background = Color.FromRgb(255, 255, 255);
                            cell2.PreferredWidth = w2;
                            cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = " ";
                            p1.Inlines.Add(s1);
                            cell2.Blocks.Add(p1);

                            row.Cells.Add(cell1);
                            row.Cells.Add(cell2);
                            table.Rows.Add(row);
                            break;
                        case 17:
                            p1 = new Paragraph();
                            s1 = new Span();
                            cell1.Background = Color.FromRgb(255, 255, 255);
                            cell1.PreferredWidth = w1;
                            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            cell1.RowSpan = 7;
                            s1.FontWeight = FontWeights.Bold;
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = name;
                            p1.Inlines.Add(s1);
                            cell1.Blocks.Add(p1);

                            p1 = new Paragraph();
                            s1 = new Span();
                            cell2.Background = Color.FromRgb(255, 255, 255);
                            cell2.PreferredWidth = w2;
                            cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = " ";
                            p1.Inlines.Add(s1);
                            cell2.Blocks.Add(p1);

                            row.Cells.Add(cell1);
                            row.Cells.Add(cell2);
                            table.Rows.Add(row);
                            for (int x = 0; x < 6; x++)
                            {
                                row = new TableRow();
                                cell2 = new TableCell();
                                p1 = new Paragraph();
                                s1 = new Span();
                                cell2.Background = Color.FromRgb(255, 255, 255);
                                cell2.PreferredWidth = w2;
                                cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                                s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                                s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                                s1.Text = " ";
                                p1.Inlines.Add(s1);
                                cell2.Blocks.Add(p1);
                                row.Cells.Add(cell2);
                                table.Rows.Add(row);
                            }
                            break;
                    }
                    nRow++;

                }
                editor.InsertTable(table);

                // Insert a field so we can identify the type of template
                //var cell = table.EnumerateChildrenOfType<TableCell>().FirstOrDefault();
                var cell = table.EnumerateChildrenOfType<TableCell>().FirstOrDefault();
                if (cell != null)
                {
                    DocumentPosition position = new DocumentPosition(doc_text.Document);
                    position.MoveToDocumentElementStart(cell.Blocks.First());
                    DocumentVariableField docVariable = new DocumentVariableField() { VariableName = "5000" };
                    editor.InsertField(docVariable);
                }
                doc_text.Document.DocumentVariables["5000"] = "";
                var field = doc_text.Document.EnumerateChildrenOfType<FieldRangeStart>().Where(x => x.Field.FieldTypeName == "DOCVARIABLE"
                && ((DocumentVariableField)x.Field).VariableName == "5000").FirstOrDefault();
                if (field != null)
                {
                    doc_text.UpdateField(field);
                }
                // Add the Datepickers
                var hrow5 = table.EnumerateChildrenOfType<TableRow>().ToList()[5];
                var hrow6 = table.EnumerateChildrenOfType<TableRow>().ToList()[6];
                var hrow17 = table.EnumerateChildrenOfType<TableRow>().ToList()[17];
                AddPurchaseDatePicker(table, hrow5);
                AddPurchaseDatePicker(table, hrow6);
                AddPurchaseDatePicker(table, hrow17);
            }
            catch (Exception e)
            {
                CGlobals cg = new CGlobals();
                cg.ShowError("TemplateHandler:PurchaseTemplate Error\n" + e.Message, 3);

            }
        }

We are then trying to insert a DateProperties into 3 cells in the table created using AddPurchaseDatePicker(Table, TableRow) :


        public void AddPurchaseDatePicker(Table table, TableRow row)
        {
            try
            {
                RadDocument document = doc_text.Document;
                RadDocumentEditor editor = new RadDocumentEditor(document);
                var dateCell = row.Cells.ToList()[1];
                DocumentPosition position = new DocumentPosition(document);
                string dateVal = string.Empty;

                var span = dateCell.EnumerateChildrenOfType<Span>().FirstOrDefault();
                if (span != null)
                {
                    dateVal = span.Text;
                    span.Text = " ";
                }
                position.MoveToDocumentElementStart(dateCell.Blocks.First());
                document.CaretPosition.MoveToPosition(position);
                editor.ChangeFontFamily(new FontFamily(CGlobals.docu_default_font));
                editor.ChangeFontSize(Unit.PointToDip(CGlobals.docu_default_font_size));
                DateProperties dataProperties = new DateProperties();
                try
                {
                    dataProperties.FullDate = DateTime.Parse(dateVal);
                }
                catch { }
               
                dataProperties.IsTemporary = false;
                dataProperties.StyleName = "TemplateFields";
                editor.InsertStructuredDocumentTag(dataProperties);
                doc_text.Document = document;
                table.Rows.ElementAdded += doc_text_NoteChanged;
            }
            catch { }
        }

When we try and set the CaretPosition with 

document.CaretPosition.MoveToPosition(position);

we recieve the following exception:

System.InvalidOperationException
  HResult=0x80131509
  Message=inline does not belong to this document.
  Source=Telerik.Windows.Controls.RichTextBox
  StackTrace:
   at Telerik.Windows.Documents.Model.RadDocument.GetContainingAnnotationRanges[TRangeStart](Inline inline, Predicate`1 filter, Boolean inclusive)
   at Telerik.Windows.Documents.Model.RadDocument.GetContainingAnnotationRanges[TRangeStart](Inline inline, Boolean inclusive)
   at Telerik.Windows.Documents.DocumentPosition.get_IsPositionInSkipPositionRange()
   at Telerik.Windows.Documents.DocumentPosition.get_IsValidPosition()
   at Telerik.Windows.Documents.DocumentPosition.Validator.EnsureValidPosition(DocumentPosition position, Func`1 shouldSearchForward)
   at Telerik.Windows.Documents.DocumentPosition.OnPositionChanged()
   at Telerik.Windows.Documents.Utils.SuspendChangingAndChangedActionCounter.InvokeChangedActionInternal()
   at Telerik.Windows.Documents.Utils.SuspendChangingAndChangedActionCounter.InvokeChanged()
   at Telerik.Windows.Documents.DocumentPosition.MoveToPosition(DocumentPosition newPosition)
   at DocuPraxis.MainWindow.AddPurchaseDatePicker(Table table, TableRow row) in E:\Source\Repos\Panarc\DocuPraxisTel\DocuPraxis\DocuPraxisTemplateHandler.cs:line 1634

We are using a similar method to add DateProperties in other generated documents without problem, e.g.:


        public void AddNotesDatePicker(Table table, TableRow row)
        {
            try
            {
                RadDocument document = doc_text.Document;
                RadDocumentEditor editor = new RadDocumentEditor(document);
                var dateCell = row.Cells.ToList()[0];
                DocumentPosition position = new DocumentPosition(document);
                string dateVal = string.Empty;
                
                var span = dateCell.EnumerateChildrenOfType<Span>().FirstOrDefault();
                if (span != null)
                {
                    dateVal = span.Text;
                    if(String.IsNullOrEmpty(dateVal) || dateVal == " " )
                    {
                        dateVal = DateTime.Now.ToString("dd/MM/yyyy");
                    }
                    span.Text = " ";
                }
                position.MoveToDocumentElementStart(dateCell.Blocks.First());
                document.CaretPosition.MoveToPosition(position);
                editor.ChangeFontFamily(new FontFamily(CGlobals.docu_default_font));
                editor.ChangeFontSize(Unit.PointToDip(CGlobals.docu_default_font_size));
                DateProperties dataProperties = new DateProperties();
                dataProperties.FullDate = DateTime.Parse(dateVal);
                dataProperties.IsTemporary = false;
                dataProperties.StyleName = "TemplateFields";
                editor.InsertStructuredDocumentTag(dataProperties);
                doc_text.Document = document;
                table.Rows.ElementAdded += doc_text_NoteChanged;
            }
            catch { }
        }
What are we doing wrong?
Dimitar
Telerik team
 answered on 07 Oct 2024
1 answer
47 views

Hi,

I need to add a DateField to a TableCell in a RichTextBox so that when a user clicks on the cell in the UI a calendar is displayed. 

I can see from the XAML that this is achieved by using the InsertSdtCommand with a CommandParameter of Date, how can a similar result be achieved from within the code.

Thank you.

 

 

Dimitar
Telerik team
 answered on 17 Sep 2024
1 answer
51 views

Hi,

When I update a table cell in a richtextbox the table is locked and I am unable to edit the table  in the UI. The change to the table cell is not shown in the

UI If I then close the current document and re-open it its fine and I can see the change made to the table cell, or if I make a change to a paragraph above the table from within the UI the change to the cell is shown, and the table is unlocked. 


        public void SetTemplateFromElement(string tagValue, string newValue)
        {
            try
            {
//                RadDocument document = doc_text.Document;
                var table = doc_text.Document.EnumerateChildrenOfType<Table>().Where(x => x.Tag == tagValue).FirstOrDefault();
                if (table != null)
                {

                    switch (tagValue)
                    {
                        case "1000":
                            var row = table.EnumerateChildrenOfType<TableRow>().FirstOrDefault();
                            var cell = row.Cells.ToList()[1];
                            cell.Blocks.Clear();
                            Paragraph p = new Paragraph();
                            Span s = new Span();
                            s.FontWeight = FontWeights.Bold;
                            s.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s.Text = newValue; ;
                            p.Inlines.Add(s);
                            cell.Blocks.Add(p);
                            break;
                        case "4000":
                            break;
                    }

                    //                    doc_text.Document = document;
                    doc_text.UpdateLayout();
                    SaveContent(strCurrentDoc);
                }
            }
            catch { }

        }

Can someone please advise.

Dimitar
Telerik team
 answered on 09 Sep 2024
1 answer
45 views

Hi,

I need to add bullets to a TableCell from code. I have tried cell.Blocks.Add(bullets) where bullets is a DocumentList but I am getting 'cannot convert from DocumentList to Block.

Code snippet:


                            DocumentList bullets = new DocumentList(DefaultListStyles.Bulleted, document);
                            p1 = new Paragraph();
                            s1 = new Span();
                            cell1.Background = Color.FromRgb(255, 255, 255);
                            cell1.PreferredWidth = w1;
                            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                            s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                            s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                            s1.Text = name;
                            p1.Inlines.Add(s1);
                            bullets.AddParagraph(p1);
                            cell1.Blocks.Add(bullets);

Thank you

Steve
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 06 Sep 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?