Telerik Forums
UI for WPF Forum
0 answers
194 views

Hi,

editor.TextFormatDefinitions.AddLast("Brace", new TextFormatDefinition(null, Brushes.Black));
...
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(new ClassificationType("Brace"))));

Nothing special - RadSyntaxEditor and those two lines in WPF. Foreground is working very well - I can highlight any part of my text as I wish. But border and background does not working ... And also unwanted behavior - foreground of other highlighting is reset when I try highlight by background change... Even just border highlighting would be sufficient ... (I want highlight closest braces.)

 

Update:

Working brace content highlighter:


internal class ExpressionTagger : CSharpTagger
{
    const string
        openBraces = "([{",
        closeBraces = ")]}";

    new RadSyntaxEditor Editor => (RadSyntaxEditor)base.Editor;

    public ExpressionTagger(RadSyntaxEditor editor) : base(editor)
    {
        editor.TextFormatDefinitions.AddLast("Class", new TextFormatDefinition(new SolidColorBrush(Color.FromRgb(43, 145, 175))));
        editor.TextFormatDefinitions.AddLast("Brace", new TextFormatDefinition(new SolidColorBrush(Color.FromRgb(155, 83, 105))));
        AddWord("Field", new ClassificationType("Class"));
        AddWord("Custom", new ClassificationType("Class"));
        AddWord("Triggers", new ClassificationType("Class"));
        StringMatchingRegex = String.Empty; // Nemá smysl, neumí najít co chceme.
        editor.CaretPosition.PositionChanged += CaretPosition_PositionChanged;
        editor.KeyDown += CaretPosition_PositionChanged;
        editor.KeyUp += CaretPosition_PositionChanged;
    }

    private void CaretPosition_PositionChanged(object sender, EventArgs e)
    {
        if (Editor.CaretPosition.Index < Document.CurrentSnapshot.Span.End)
        {
            char currentChar = Document.CurrentSnapshot.GetText(new Span(Editor.CaretPosition.Index, 1))[0];
            if (MultilineTags.Any(tag => tag.Tag.ClassificationType.Name == "Brace") ||
                (KeyboardModifiers.IsAltDown && (openBraces.Contains(currentChar) || closeBraces.Contains(currentChar))))
            {
                InvalidateMultilineTags();
            }
        }
    }

    protected override void RebuildMultilineTags()
    {
        base.RebuildMultilineTags();

        string text = Editor.Document.CurrentSnapshot.GetText();
        foreach (Match literal in Regex.Matches(text, "\"(?:[^\"]|\"{2})*\""))
        {
            TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(Document.CurrentSnapshot,
                new Span(literal.Groups[0].Index, literal.Groups[0].Length));
            MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(ClassificationTypes.StringLiteral)));
        }
        if (KeyboardModifiers.IsAltDown)
        {
            int
                startIndex = Editor.CaretPosition.Index,
                searchIndex = 1,
                closeIndex = 0;
            char currentChar = Document.CurrentSnapshot.GetText(new Span(Editor.CaretPosition.Index, 1))[0];

            int braceIndex = openBraces.IndexOf(currentChar);
            if (braceIndex > -1)
            {
                char
                    openBrace = currentChar,
                    closeBrace = closeBraces[braceIndex];
                closeIndex = startIndex + 1;

                while (searchIndex > 0 && closeIndex < text.Length)
                {
                    currentChar = text[closeIndex];
                    if (currentChar == openBrace)
                    {
                        searchIndex++;
                    }
                    if (currentChar == closeBrace)
                    {
                        searchIndex--;
                    }
                    closeIndex++;
                }
                closeIndex--;
                currentChar = char.MinValue; // reset
            }
            braceIndex = closeBraces.IndexOf(currentChar);
            if (braceIndex > -1)
            {
                char
                    openBrace = openBraces[braceIndex],
                    closeBrace = currentChar;
                closeIndex = startIndex;
                startIndex--;

                while (searchIndex > 0 && startIndex > 0)
                {
                    currentChar = text[startIndex];
                    if (currentChar == closeBrace)
                    {
                        searchIndex++;
                    }
                    if (currentChar == openBrace)
                    {
                        searchIndex--;
                    }
                    startIndex--;
                }
                startIndex++;
            }
            if (searchIndex == 0) // Found
            {
                TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(Document.CurrentSnapshot,
                    new Span(startIndex, closeIndex - startIndex + 1));
                MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(new ClassificationType("Brace"))));
            }
        }
    }
}
Just it is ugly, because I am able only to change Foreground. How can I at least use Find border boxes or any better highlight option?
Matt
Top achievements
Rank 1
 updated question on 08 Dec 2022
0 answers
143 views
We have implemented custom timeline intervals for radtimeline which was working fine with earlier version of Telerik framework(2019) but after the upgrade to latest(R3 2022 SP1) Telerik framework, with custom intervals the timeline is not loading when customization is removed it works fine(default timeline intervals).

Is there any change with new framework we should be considering?

We are currently testing out the Telerik Upgrade with Demo version of the framework(R3 2022 SP1). Could this be an issue?
Shivam
Top achievements
Rank 1
Iron
 asked on 07 Dec 2022
0 answers
126 views

Hello,

in my Docking-Control, I want to highlight one specific RadPane at runtime (everywhere - un/pinned, floating, etc.).
I want only this RadPane to use different colors, than the others.

I was able to set the appreance for all of them, but not for a specific one.

How can I achieve the desired behaviour?

Melanie
Top achievements
Rank 1
 asked on 06 Dec 2022
0 answers
217 views

Hi,

We have an issue with a custom column we used in RadGridView.

 

There is a scenario when a column, hence a whole row is not selectable. Please see the attached sample solution and follow below scenario:

1. Scroll to Col5 which is editable,

2. Edit Col5 value

3. Click a column next to Col5 in the same row (to accept the value in Col5 cell),

4. Scroll to the left to see Id column

5. Select the row by clicking on Id cell In the same row.

The issue is that the row is not possible to be selected nor the checkbox in the column is ticked.

 

Can you advise?

Thanks,

Łukasz

Licensing
Top achievements
Rank 1
 asked on 06 Dec 2022
1 answer
134 views

Hi,

When you select a cell, the formula is shown in the formula text box. You click on a part of the formula to edit it at a certain spot and the cursor is positioned there but then instantly jumps to the end of the formula requiring you to click in the certain spot again.

This is very frustrating when you want to edit a formula.

This behavior can be seen in WPF demos.

Regards

Anthony

Dimitar
Telerik team
 answered on 06 Dec 2022
1 answer
155 views

When the RadOutlookBar is in the minimized state, I want to trigger the content popup when a RadOutlookBarItem element is clicked, exactly as if MinimizedContentElement (a RadDropDownButton) had been clicked.

My imperfect solution adds a Click event to the RadOutlookBarItem element (which is not a button and only has MouseUp/MouseDown) with an attached property, and when this event is raised MinimizedContentElement.IsOpen is set to true which triggers the popup. (The RadOutlookBar.SelectionChanged event is not used because it is not raised if the item is already selected.)

The issue I have is that the popup stays open when there is a mouse click elsewhere in the window, even with MinimizedContentElement.KeepOpen=false and CloseOnPopupMouseLeftButtonUp=true. When the popup is triggered with a click on MinimizedContentElement, it closes automatically which is the behaviour I desire.

What's the simplest way to achieve this?

 

Thanks for any assistance you can provide.

Dilyan Traykov
Telerik team
 answered on 06 Dec 2022
5 answers
356 views

I am getting a memory leak problem with Radrichtextbox. I continually create a rich text bus and print. this Radrichtextbox was added to the canvas container then its measured child size and arranged elements every time it went from this procedure it increased huge memory and never goes down, for example, creating 500 Radrichtextbox consumes more than 400 memory. I saw an increase when the parent container try to measure with the specific size and then arrange it and update the layout. I am unable to find which thing retains Radrichtextbox alive in memory. I attached some memory screenshots. i am using telerik version 2021. 1. 119. 45

junaid
Top achievements
Rank 1
Iron
 answered on 06 Dec 2022
1 answer
275 views

Hello,

I am using Telerik UI for WPF 5.0 version 2021.3.1109 (NoXAML version) in Visual Studio 16.11.17.

My problem is that the WPF UI designer does not display the telerik RadWindows I design. The error message is:

XDG0062 The resource "RadWindowStyle" could not be resolved.

I already followed the instructions given in this KB article. This article especially mentions to include the following XAML in my RadWindows, but that did not solve my problem:

<telerik:RadWindow (namespaces omitted) ... Style="{StaticResource RadWindowStyle}"/> 

In my Application file, I have a Style declaration like this:

<ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/System.Windows.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Input.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.GridView.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.FileDialogs.xaml"/>
                <ResourceDictionary>
                    <Style TargetType="views:MainWindow" BasedOn="{StaticResource RadWindowStyle}" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

In the application file, I do not get the above error message (XDG0062).

So I concluded that somehow, my Window classes (e.g. MainWindow) don't receive the declared styles.

Important: I have setup my project as a Console Project (because I must implement a CLI and this was the easiest way). The UI is started with the following C# lines of code in Program.cs:

Application app = new Appl();
app.Run();
Type Appl is my WPF Application XAML.
The application runs fine when started but it would be great to use the XAML designer in VS as intended. Can you please provide some help?
Philipp
Top achievements
Rank 1
Iron
 answered on 05 Dec 2022
1 answer
149 views
How do you programmatically close a tab in TabbedWindow?
Stenly
Telerik team
 answered on 05 Dec 2022
1 answer
245 views

We have a RadListBox bound to a ObservableCollection of models.  We would like sort them based on a property.  The property value can also change.  Is there any way to sort them?

What we are trying to do is create a "mover" to rank items, is a RadListBox not the best choice?

Martin Ivanov
Telerik team
 answered on 02 Dec 2022
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?