This is a migrated thread and some comments may be shown as answers.

SyntaxEditor inside a LayoutControl

2 Answers 182 Views
SyntaxEditor
This is a migrated thread and some comments may be shown as answers.
Georg
Top achievements
Rank 1
Veteran
Georg asked on 21 Dec 2020, 03:50 PM

The SyntaxEditor is great! I'd like to use it inside a LayoutControl though, basically like this:

    <telerik:RadLayoutControl >
        <telerik:LayoutControlGroup Orientation="Vertical">
            <telerik:LayoutControlGroup Orientation="Horizontal">
                <telerik:LayoutControlSplitter />
                <telerik:RadSyntaxEditor />
            </telerik:LayoutControlGroup>
            <telerik:LayoutControlSplitter />
        </telerik:LayoutControlGroup>
    </telerik:RadLayoutControl>

I have that working with a fixed size editor, but it would be much nicer if the editor resized when the splitters were moved. However, if I don't make the editor fixed size I get the error "Placing RadSyntaxEditor in a panel or control that measures it with infinite height is not supported unless height is set to the control".

Is there a work-around for this? If not, could you add support in a future release?

Regards,

Georg

 

 


 

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 23 Dec 2020, 09:14 AM

Hello Georg,

The reason of the exception is that such controls with built-in UI virtualization (SyntaxEditor, GridView, ListBox) looses its ability to virtualize. No size of the child in panel which measures its children with infinity means no understanding of how many containers should be in the viewport. In some controls you simply loose the virtualization resulting in poor performance and in other we throw an exception, mostly in control where virtualization feature has no property for disabling it.
Here is a short idea for a workaround - initial fixed size of the editor and wrapping a canvas around the SyntaxEditor and updating the Size of the editor via the canvas size (actually you can try this with XAML binding to ActualHeight too):

		<telerik:RadLayoutControl  Grid.Row="1">
			<telerik:LayoutControlGroup Orientation="Vertical">
				<telerik:LayoutControlGroup Orientation="Horizontal">
					<telerik:LayoutControlSplitter />
					<Canvas SizeChanged="Grid_SizeChanged" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
					   <telerik:RadSyntaxEditor x:Name="editor" Height="600" Width="800"/>
					</Canvas>
				</telerik:LayoutControlGroup>
				<telerik:LayoutControlSplitter />
			</telerik:LayoutControlGroup>
		</telerik:RadLayoutControl>
        private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Debug.WriteLine(e.NewSize.Height);
            this.editor.Height = e.NewSize.Height;
        }

Regards,
Petar Mladenov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Georg
Top achievements
Rank 1
Veteran
answered on 09 Mar 2021, 02:54 PM
Thanks Petar - that worked very well!
Tags
SyntaxEditor
Asked by
Georg
Top achievements
Rank 1
Veteran
Answers by
Petar Mladenov
Telerik team
Georg
Top achievements
Rank 1
Veteran
Share this question
or