Telerik Forums
UI for WPF Forum
1 answer
285 views

I have a RadGridView inside that 2 different column i have a cell template and a datatemplate in that i have the RichTextbox inside that paragraph inside that run and the text property binded on it.

 

Now i need to compare tow richtexbox text value. If any RichTextbox value is different it need to be highlighted inside thta text Box.

XAML

                    

<RadGridView Grid.Row="1" x:Name="gfgvBrokenLinks" AutoGenerateColumns="False" ItemsSource="{Binding BrokenLinks}" IsReadOnly="True" AutoExpandGroups="False" RowLoaded="gfgvBrokenLinks_RowLoaded">

<telerik:GridViewDataColumn DataMemberBinding="{Binding Data1}"  Header="Data1" IsGroupable="False">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <RichTextBox x:Name="richTextBox2" MinWidth="100" IsReadOnly="True">
                                    <FlowDocument >
                                        <Paragraph>
                                            <Run Text="{Binding Data1,Mode=OneWay}"></Run>
                                        </Paragraph>
                                    </FlowDocument>
                                </RichTextBox>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Data2}" Header="{my:LocString ResourceKey=HeaderData2}" IsGroupable="False" >
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <RichTextBox x:Name="richTextBox3" MinWidth="100" IsReadOnly="True" >
                                    <FlowDocument >
                                        <Paragraph>
                                            <Run Text="{Binding Data2,Mode=OneWay}"></Run>
                                        </Paragraph>
                                    </FlowDocument>
                                </RichTextBox>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>

 

 

 

c#


private void gfgvBrokenLinks_RowLoaded"object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{



if (e.Row.Cells.Count > 0)
{
RichTextBox rt1 = e.Row?.Cells[8]?.Content as RichTextBox;
RichTextBox rt2 = e.Row?.Cells[9]?.Content as RichTextBox;
if (rt1 != null && rt2 != null)
{
string a1 = StringFromRichTextBox(rt1);
string a2 = StringFromRichTextBox(rt2);
if (!a1.Equals(a2))
{
int startindex = 0;
startindex = a1.Zip(a2, (c1, c2) => c1 == c2).TakeWhile(b => b).Count();
int length = a2.Length - startindex;
Select(rt2, startindex, length, Colors.Yellow);
}



//string text = new TextRange(rt2.Document.ContentStart, rt2.Document.ContentEnd).Text;
//if (text.Length > 0)
//{
// TextPointer myTextPointer1 = rt2.Document.ContentStart.GetPositionAtOffset(startindex + 1);
// TextPointer myTextPointer2 = rt2.Document.ContentEnd;
// if (myTextPointer1 != null && myTextPointer2 != null)
// {
// TextRange tr = new TextRange(myTextPointer1, myTextPointer2);
// tr.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.Yellow);
// }
//}
}
}
}



private static TextPointer GetTextPointAt(TextPointer from, int pos)
{
TextPointer ret = from;
int i = 0;



while ((i < pos) && (ret != null))
{
if ((ret.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text) || (ret.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.None))
{
i++;
}



if (ret.GetPositionAtOffset(1, LogicalDirection.Forward) == null)
{
return ret;
}



ret = ret.GetPositionAtOffset(1, LogicalDirection.Forward);
}



return ret;
}



internal string Select(RichTextBox rtb, int offset, int length, Color color)
{
// Get text selection:
TextSelection textRange = rtb.Selection;



// Get text starting point:
TextPointer start = rtb.Document.ContentStart;



// Get begin and end requested:
TextPointer startPos = GetTextPointAt(start, offset);
TextPointer endPos = GetTextPointAt(start, offset + length);



// New selection of text:
textRange.Select(startPos, endPos);



// Apply property to the selection:
textRange.ApplyPropertyValue(TextElement.BackgroundProperty, new SolidColorBrush(color));



// Return selection text:
return rtb.Selection.Text;
}

private string StringFromRichTextBox(RichTextBox rtb)
{
TextRange textRange = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
return textRange.Text.Replace("\r\n", "");
}

Thanks In Advance

Dilyan Traykov
Telerik team
 answered on 12 Oct 2021
1 answer
205 views

Hi, 

I want to change the Time Button Style of RadDateTimePicker, like mouseover or pressed style.

But i cannot find it in tempalte.

Masha
Telerik team
 answered on 12 Oct 2021
1 answer
770 views

Hello.

Inside the gridview is a hierarchical gridview.

I created a button of the column cell template in the hierarchical grid view.

How to bind this button and how to receive parameters?

Upload a simple example image and source.


<telerik:RadGridView x:Name="xMain"  ItemsSource="{Binding Main}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Name"  DataMemberBinding="{Binding Name}"/>
        <telerik:GridViewColumn Header="View" Width="80" HeaderTextAlignment="Center" TextAlignment="Center">
            <telerik:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <telerik:RadButton	Content="MainButton"
										Command="{Binding DataContext.OnClickCommand, RelativeSource={RelativeSource FindAncestor,AncestorType=telerik:RadGridView}}"
										CommandParameter="{Binding}">
                    </telerik:RadButton>
                </DataTemplate>
            </telerik:GridViewColumn.CellTemplate>
        </telerik:GridViewColumn>

        <telerik:RadGridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition>
            <telerik:GridViewTableDefinition.Relation>
                <telerik:PropertyRelation ParentPropertyName="Subs" />
            </telerik:GridViewTableDefinition.Relation>
        </telerik:GridViewTableDefinition>
    </telerik:RadGridView.ChildTableDefinitions>

    <telerik:RadGridView.HierarchyChildTemplate>
        <DataTemplate>
                <telerik:RadGridView x:Name="xSubs" ItemsSource="{Binding Subs}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Name"  DataMemberBinding="{Binding Name}"/>
                    <telerik:GridViewColumn Header="View" Width="80" HeaderTextAlignment="Center" TextAlignment="Center">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadButton	Content="SubButton"
													Command="{Binding DataContext.OnClickCommand, RelativeSource={RelativeSource FindAncestor,AncestorType=telerik:RadGridView}}"
													CommandParameter="{Binding}">
                                </telerik:RadButton>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </DataTemplate>
    </telerik:RadGridView.HierarchyChildTemplate>
</telerik:RadGridView>

It is bound to the same OnClickCommand and will receive an object to identify it.

(CommandParameter is the selecteditem that is bound to the GridView.)

 

MainButton working / SubButton not working

I also tried setting Mode=TemplatedParent of RelativeSource and other settings, but couldn't find a solution.

I will wait for your reply.
thank you.
Stenly
Telerik team
 answered on 12 Oct 2021
1 answer
179 views

I am using radgridview on my project to display collection of data and I got an exception when I resize column. please find attachment for your reference. Application is also crashed so please help me out from this.

First jpeg : I got an exception whenever I tried to resize column

Second jpeg : I got an exception whenever I do mouse double click on radgridview row

 

 

 

Thanks & Regards

Murugansilvers M

Dilyan Traykov
Telerik team
 answered on 12 Oct 2021
1 answer
134 views

Hi,

I am using radribboncombobox to display toolbar.we want to display combobox like shown in image.

last item as default item i.e "manage filters"  in combobox and also other items are grouped as per category "shared" or "personal".

 

is it possible?

How to do it using template.?

Dilyan Traykov
Telerik team
 answered on 12 Oct 2021
1 answer
375 views

I have a RadSplitContainer docking in an application and when I do the following it either returns DockedLeft or DockedBottom, however I can see that's not correct:

var docking = RadDocking.GetDockState(container)

If I ask for the width and height, I get fixed numbers, not the actual size of the container:

var width = container.ActualWidth;
var height = container.ActualHeight;

Stenly
Telerik team
 answered on 08 Oct 2021
0 answers
257 views
Hi Telerik Team,

While doing the drag and drop functionality, to locate the place of the card while dropping we are having a ORANGE line(drop preview line)refer image in attachment. But we need all the other cards to be re-arranged like below.

Let us consider I'm trying to drag the 5th card between 2nd and 3rd cards. While hovering(drop-preview line will be visibile) between the 2nd and 3rd card I need the 3rd card to be moved a little bit down by making space for the 5th card there.(i.e- iphone drag drop capability's)  i.e (below the drop-preview line- empty space has to be there(Size of dragged item)  and after that remaining cards must be there) in RAD LIST BOX CONTROL used listbox dragdropbehvaiour and screenshot behavior for drag drop operation's.


Can you provide solution for this.

Thanks and Regards,

Kishore Kumar
Kishorekumar
Top achievements
Rank 1
Veteran
 asked on 08 Oct 2021
3 answers
301 views
I have List of objects (class with 2 int members for x and y value).
Created ChartView with several line series, sharing 1 horizontal and 1 vertical axis between all of them, but when I'm trying to set horizontal axis type to LinearAxis, it just doesn't show any data. When setting it to CategorialAxis - everything works fine. But only LinearAxis fits my needs.
Martin Ivanov
Telerik team
 updated answer on 08 Oct 2021
1 answer
614 views

This question seems related to .Net, but as I am using Telerik UI WPF noXaml 2021 R2 assemblies. I have doubt that Telerik controls might causing this error.

I have published .Net 5 SCD x-86 wpf application on client machine which has win 7 OS. As client machines are outdated, therefore we provided them self contained deployment. 

Our application is importing Telerik UI for WPF noXaml 2021 R2 assemblies, and  using Font Glyph. FontResources.xaml is imported at application startup. Other than that application is using default fonts.

As following errors shows, application is unable to create font (may be font not found/ corrupted fonts), and I guess Telerik Font Glyph is using fonts which is not available in older OS like Win 7.

System.IO.FileFormatException: Invalid file format.
at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)
at MS.Internal.Text.TextInterface.Font.CreateFontFace()
at MS.Internal.Text.TextInterface.Font.AddFontFaceToCache()
at MS.Internal.Text.TextInterface.Font.GetFontFace()
at System.Windows.Media.GlyphTypeface..ctor(Font font)
at MS.Internal.FontFace.PhysicalFontFamily.GetGlyphTypeface(FontStyle style, FontWeight weight, FontStretch stretch)
at MS.Internal.FontFace.PhysicalFontFamily.MS.Internal.FontFace.IFontFamily.GetTypefaceMetrics(FontStyle style, FontWeight weight, FontStretch stretch)
at System.Windows.Media.Typeface.ConstructCachedTypeface()
at System.Windows.Media.Typeface.get_CachedTypeface()
at System.Windows.Media.Typeface.CheckFastPathNominalGlyphs(CharacterBufferRange charBufferRange, Double emSize, Single pixelsPerDip, Double scalingFactor, Double widthMax, Boolean keepAWord, Boolean numberSubstitution, CultureInfo cultureInfo, TextFormattingMode textFormattingMode, Boolean isSideways, Boolean breakOnTabs, Int32& stringLengthFit)
at MS.Internal.TextFormatting.SimpleRun.CreateSimpleTextRun(CharacterBufferRange charBufferRange, TextRun textRun, TextFormatterImp formatter, Int32 widthLeft, Boolean emergencyWrap, Boolean breakOnTabs, Double pixelsPerDip)
at MS.Internal.TextFormatting.SimpleRun.Create(FormatSettings settings, CharacterBufferRange charString, TextRun textRun, Int32 cp, Int32 cpFirst, Int32 runLength, Int32 widthLeft, Int32 idealRunOffsetUnRounded, Double pixelsPerDip)
at MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings settings, Int32 cpFirst, Int32 paragraphWidth, Double pixelsPerDip)
at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
at System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Window.MeasureOverrideHelper(Size constraint)
at System.Windows.Window.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at System.Windows.Window.SetRootVisual()
at System.Windows.Window.SetRootVisualAndUpdateSTC()
at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
at System.Windows.Window.CreateSourceWindowDuringShow()
at System.Windows.Window.SafeCreateWindowDuringShow()
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.Show()
at eOffice.App.OnStartup(Object sender, StartupEventArgs e)
at System.Windows.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Martin Ivanov
Telerik team
 answered on 07 Oct 2021
1 answer
385 views

When I import html document to HtmlFormatProvider, I noticed empty line at beginning of each paragraph. When I exported same document as html document. I found empty paragraph is added, which causing extra spacing. Our challenge is to remove such extra spaces, so that all text in columns are same aligned. 

 

Following is actual document content

<body><p class="NormalWeb "><span class="s_B0779B8D">some text here</span></p><p class="Normal ">&nbsp;</p></body>

While following is generated html document (First para is not part of actual document. and same rendered in richtextbox editor. which adds extra space on top)

<p class="NormalWeb ">
	<span class="s_DED8E654"> </span>
</p>
<p class="NormalWeb ">
	<span class="s_BCF031D1">some text here</span>
</p>
<p class="Normal ">&nbsp;</p>

I am using following code to import html into editor


using (Stream input = new MemoryStream(Encoding.Default.GetBytes(html)))
{
	HtmlFormatProvider provider = new HtmlFormatProvider();
	provider.ImportSettings = new HtmlImportSettings
	{
		UseDefaultStylesheetForFontProperties = false,
		UseHtmlHeadingStyles = false
	};
	RadDocument document = provider.Import(input);
	editor.Document = document;

	editor.Document.StyleRepository["NormalWeb"].ParagraphProperties.SpacingBefore = 0;
	editor.Document.StyleRepository["NormalWeb"].ParagraphProperties.SpacingAfter = 0;
	editor.Document.StyleRepository["NormalWeb"].ParagraphProperties.AutomaticSpacingAfter = false;

}

 

For reference I am attaching actual html document, exported html document and rendering in user interface.

 

 

 

 

Ivan Ivanov
Telerik team
 answered on 06 Oct 2021
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?