Telerik Forums
UI for WPF Forum
1 answer
85 views

Hi,

We are creating a table and adding it to a RichTextBox:


        public void AddAddress()
        {
            string addrName = string.Empty;
            string[] rowName = new string[] { "Job Title", "Employer", "Address", "Tel.", "Tel. Dir.", "Mobile", "Email", "Website", "Fax", "Details", "Address", "Tel.", "Mobile", "Email", "Details" };
            if(_selelement != null)
            {
                addrName = _selelement.GetAttribute("title");
            }
            SdtProperties sdtProperties = new SdtProperties(SdtType.RichText)
            {
                Alias = "AddressName",
                Lock = Lock.SdtContentLocked,
                ID = 1001,
            };
            RadDocument document = new RadDocument();
            Section section = new Section();

            TableWidthUnit w1 = new TableWidthUnit(100);
            TableWidthUnit w2 = new TableWidthUnit(520);

            Table table = new Table();
            table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

            TableRow row1 = new TableRow();
            TableCell cell1 = new TableCell();
            cell1.Background = Color.FromRgb(174, 255, 190);
            cell1.PreferredWidth = w1;
            cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
            Paragraph p1 = new Paragraph();
            p1.Background = Color.FromRgb(174, 255, 190);
            Span s1 = new Span();
            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);
            row1.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            cell2.Background = Color.FromRgb(174, 255, 190);
            cell2.PreferredWidth = w2;
            cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
            Paragraph p2 = new Paragraph();
            p2.Background = Color.FromRgb(174, 255, 190);
            Span s2 = new Span();
            s2.FontWeight = FontWeights.Bold;
            s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
            s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
            s2.Text = addrName;
            p2.Inlines.Add(s2);
            cell2.Blocks.Add(p2);
            row1.Cells.Add(cell2);
            table.Rows.Add(row1);

            int rowCount = 0;
            foreach(string rname in rowName)
            {
                rowCount++;
                row1 = new TableRow();
                cell1 = new TableCell();
                p1 = new Paragraph();
                if (rowCount < 11)
                {
                    cell1.Background = Color.FromRgb(255, 229, 153);
                    p1.Background = Color.FromRgb(255, 229, 153);
                }
                else
                {
                    cell1.Background = Color.FromRgb(196, 255, 255);
                    p1.Background = Color.FromRgb(196, 255, 255);
                }
                cell1.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                s1 = new Span();
                s1.FontWeight = FontWeights.Bold;
                s1.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s1.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s1.Text = rname;
                p1.Inlines.Add(s1);
                cell1.Blocks.Add(p1);
                row1.Cells.Add(cell1);

                cell2 = new TableCell();
                cell2.Background = Color.FromRgb(255, 255, 255);
                cell2.Padding = new Telerik.Windows.Documents.Layout.Padding(3, 6, 3, 6);
                p2 = new Paragraph();
                s2 = new Span();
                s2.FontFamily = new FontFamily(CGlobals.docu_default_font);
                s2.FontSize = Unit.PointToDip(CGlobals.docu_default_font_size);
                s2.Text = " ";
                p2.Inlines.Add(s2);
                cell2.Blocks.Add(p2);
                row1.Cells.Add(cell2);
                table.Rows.Add(row1);
            }

            section.Blocks.Add(new Paragraph());
            section.Blocks.Add(table);
            section.Blocks.Add(new Paragraph());
            document.Sections.Add(section);

            doc_text.Document = document;   
        }

How can we add a Content Control with StdProperties to one of the table cells, similar to:

SdtProperties sdtProperties = new SdtProperties(SdtType.RichText) 
{ 
    Alias = "AliasName", 
    Lock = Lock.SdtContentLocked, 
}; 
doc_text.InsertStructuredDocumentTag(sdtProperties); 

Dimitar
Telerik team
 answered on 26 Jul 2024
1 answer
137 views
how add spinner to WPF Application
Stenly
Telerik team
 answered on 25 Jul 2024
1 answer
62 views

I have the following XAML code:

<telerik:RadLayoutControl >
    <telerik:RadTabControl>
        <telerik:RadTabItem Header="Admin">
            <telerik:RadTabItem.Content>
                <telerik:RadLayoutControl>
				
                    <!-- Left Side -->
                    <telerik:RadTreeListView Name="TreeListView" ItemsSource="{Binding Arguments}">
                        <telerik:RadTreeListView.ChildTableDefinitions>
                            <telerik:TreeListViewTableDefinition ItemsSource="{Binding Children}" />
                        </telerik:RadTreeListView.ChildTableDefinitions>
                    </telerik:RadTreeListView>
					
                    <telerik:LayoutControlSplitter />

                    <!-- Right Side -->
                    <telerik:RadTabControl Width="Auto">
                        <telerik:RadTabItem Header="Tab 1">
                            <telerik:RadGridView></telerik:RadGridView>
                        </telerik:RadTabItem>
                        <telerik:RadTabItem Header="Tab 2">
                            <telerik:RadGridView></telerik:RadGridView>
                        </telerik:RadTabItem>
                    </telerik:RadTabControl>

                </telerik:RadLayoutControl>
            </telerik:RadTabItem.Content>
        </telerik:RadTabItem>
    </telerik:RadTabControl>
</telerik:RadLayoutControl>

The problem is that when I populate the TreeListView with big number of items, it stretches the topmost RadLayoutControl parent (look at the scrollbar position on the far right). The behavior I expect is that the TreeListView itself gets a vertical scrollbar like when I set it to a fixed Height. But I want it to be resizable with the window.

How can I achieve such behavior?

Martin Ivanov
Telerik team
 answered on 24 Jul 2024
1 answer
81 views

Hey,

since the last Update, my GridViews with a CellEditTemplate (for example DateTimePickers or MaskedTextInputs) dont show the red Validation Error indicators anymore, if ValidatesOnDataErrors is set to InEditMode.

If you hover over the location where the error should show you can still see it, but no red indicator whatsoever.

If ValidatesOnDataErrors is set to ViewMode it works.
If no CellEditTemplate is set, it works too.

Heres the code of the gridview:

        <telerik:RadGridView
            x:Name="rgv"
            GroupRenderMode="Flat"
            ShowGroupPanel="False"
            FilteringMode="Popup"
            ShowSearchPanel="False"
            CanUserSearch="False"
            ValidatesOnDataErrors="InEditMode"
            AlternationCount="2"
            ActionOnLostFocus="CommitEdit"
            CanUserDeleteRows="True"
            IsSynchronizedWithCurrentItem="True"
            ShowColumnFooters="True"
            SelectionMode="Single"
            IsPropertyChangedAggregationEnabled="False"
            VirtualizingPanel.VirtualizationMode="Recycling"
            NewRowPosition="Top"
            AutoGenerateColumns="False"
            >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn
                    DataMemberBinding="{Binding RechnungsNr}"
                    Header="Rechnung Nr."
                    TextWrapping="Wrap"
                    HeaderTextWrapping="Wrap"
                    Width="100"
                    >
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <telerik:RadMaskedTextInput
                                Value="{Binding RechnungsNr, Mode=TwoWay, UpdateSourceTrigger=Explicit}"    
                                maskedInput:MaskedInputExtensions.MaxTextLength="255"
                                Mask=""
                                MinWidth="100"
                                InputBehavior="Insert"
                                IsClearButtonVisible="False"
                                />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="Anzahl:  " ResultFormatString="{}{0:N0}" />
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

 

And also the whole sample project:
https://we.tl/t-11ppqbB7EG

 

Did I miss something I have to change after the update?

Greetings
Benedikt

Stenly
Telerik team
 answered on 23 Jul 2024
0 answers
27 views
I have a docx file and it contains line numbers like the image below.



When I use the PdfFormatProvider to convert the docx to pdf the line numbers do not display on the PDF. However, if I manually open the document and save as a PDF they do.

Is there something I am missing here?
Patrick
Top achievements
Rank 1
 asked on 19 Jul 2024
1 answer
69 views

Hello,

I need to export radgridview data. Here data is grouped and groupheader template is applied.

Current Export feature exports only group member and not the content inside GroupHeaderTemplate. Kindly provide help.

 

Martin Ivanov
Telerik team
 answered on 18 Jul 2024
0 answers
52 views
In a WPF project using Telerik, I have a RadGridView where I’ve centered the text alignment. This works perfectly in normal mode, but during editing, the text reverts to left alignment.
How can I change the text alignment in editing mode for RadGridView, preferably through XAML?
Alice
Top achievements
Rank 1
 asked on 16 Jul 2024
1 answer
77 views

RadCircularProgressBar IsIndeterminate animation is not working when placed inside a RadWindow with RadWindowInteropHelper.AllowTransparency set to 'false'.

I attached a project reproducing the behaviour.

Version 2024 Q2

Stenly
Telerik team
 answered on 15 Jul 2024
0 answers
88 views

I'm trying to capture when the Enter key is pressed in a RadWatermarkTextBox without adding code to code-behind.

In the XAML I have:


            <telerik:RadWatermarkTextBox MinHeight="26"
                                         x:Name="searchCompleteBox"
                                         VerticalAlignment="Center"
                                         Text="{Binding SearchText, Mode=TwoWay}"
                                         Width="200" 
                                         WatermarkContent="Enter name, address, or ID">
                <telerik:EventToCommandBehavior.EventBindings>
                    <telerik:EventBinding Command="{Binding OnSearchCompleteBoxKeyDownCommand}"
                                     EventName="KeyDown"
                                     PassEventArgsToCommand="True" />
                </telerik:EventToCommandBehavior.EventBindings>
            </telerik:RadWatermarkTextBox>

In the ViewModel:


    private async void OnSearchCompleteBoxKeyDown(System.Windows.Input.KeyEventArgs e)
    {        
        if (e.Key == Key.Enter)
        {
            await SearchForMembersAsync();
        }
    }

The problem is SearchText is not updating. So if I type something like "smith" OnSearchCompleteBoxKeyDown fires five times, the if result is false five times, but SearchText contains an empty string instead of "smith".

SearchText is declared properly and is updated properly if I take the EventToCommandBehavior code out.  This all works properly if I use code-behind but I want to avoid that.

Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
 asked on 14 Jul 2024
1 answer
100 views

Hello, I have two questions regarding the RadCartesianChart Annotations.

Question 1:

I have attached an example project to this question. When I first open the example project the text of the Annotation seems to be cut off. This fixes itself if the window is resized and the problem doesn't seem to occur again. Is there a way to not have this cut off text? Am I setting a property incorrectly?

 

Question 2:

In the same attached project I have one of the annotation labels set to the location bottom; however, I can't seem to find it in my window. Is there something I am missing to get this text to show up?

 

Here is the relevant xaml:


<telerik:RadCartesianChart Grid.Row="1" >

    <telerik:RadCartesianChart.Annotations>

        <telerik:CartesianGridLineAnnotation Value="20" Stroke="Red" FontSize="20" StrokeThickness="5" Axis="{Binding ElementName=horizontalAxis1}" Label="Example" Foreground="Black">
            <telerik:CartesianGridLineAnnotation.LabelDefinition>
                <telerik:ChartAnnotationLabelDefinition Location="Inside" HorizontalAlignment="Center" />
            </telerik:CartesianGridLineAnnotation.LabelDefinition>
        </telerik:CartesianGridLineAnnotation>

        <telerik:CartesianGridLineAnnotation Value="25" Stroke="Red" FontSize="20" StrokeThickness="5" Axis="{Binding ElementName=horizontalAxis1}" Label="Example" Foreground="Black">
            <telerik:CartesianGridLineAnnotation.LabelDefinition>
                <telerik:ChartAnnotationLabelDefinition Location="Inside" HorizontalAlignment="Center" />
            </telerik:CartesianGridLineAnnotation.LabelDefinition>
        </telerik:CartesianGridLineAnnotation>

        <telerik:CartesianGridLineAnnotation Value="30" Stroke="Red" FontSize="20" StrokeThickness="5" Axis="{Binding ElementName=horizontalAxis1}" Label="Example" Foreground="Black">
            <telerik:CartesianGridLineAnnotation.LabelDefinition>
                <telerik:ChartAnnotationLabelDefinition Location="Bottom" HorizontalAlignment="Center" />
            </telerik:CartesianGridLineAnnotation.LabelDefinition>
        </telerik:CartesianGridLineAnnotation>
    </telerik:RadCartesianChart.Annotations>

    <telerik:RadCartesianChart.Series>
        <telerik:BarSeries ShowLabels="True"
                           CategoryBinding="Category"
                           ValueBinding="Value">

            <telerik:BarSeries.LabelDefinitions>

                <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Center">
                    <telerik:ChartSeriesLabelDefinition.DefaultVisualStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="White"/>
                        </Style>
                    </telerik:ChartSeriesLabelDefinition.DefaultVisualStyle>
                </telerik:ChartSeriesLabelDefinition>

                <telerik:ChartSeriesLabelDefinition HorizontalAlignment="Center" VerticalAlignment="Top">
                    <telerik:ChartSeriesLabelDefinition.Template>
                        <DataTemplate>
                            <TextBlock Foreground="#5AA4D4" FontWeight="Bold" Text="{Binding DataItem.Value}" />
                        </DataTemplate>
                    </telerik:ChartSeriesLabelDefinition.Template>
                </telerik:ChartSeriesLabelDefinition>

            </telerik:BarSeries.LabelDefinitions>

            <telerik:BarSeries.DataPoints>
                <telerik:CategoricalDataPoint Category="Apples" Value="20"/>
                <telerik:CategoricalDataPoint Category="Bananas" Value="28"/>
                <telerik:CategoricalDataPoint Category="Oranges" Value="17"/>
                <telerik:CategoricalDataPoint Category="Strawberries" Value="30"/>
            </telerik:BarSeries.DataPoints>
        </telerik:BarSeries>
    </telerik:RadCartesianChart.Series>

    <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:LinearAxis x:Name="horizontalAxis1"/>
    </telerik:RadCartesianChart.HorizontalAxis>
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:CategoricalAxis/>
    </telerik:RadCartesianChart.VerticalAxis>


</telerik:RadCartesianChart>

Thank You,

Giuliano

Martin Ivanov
Telerik team
 answered on 12 Jul 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?