Telerik Forums
UI for WPF Forum
1 answer
103 views

Hello,

In the RichTextBox, in the Table, what is the best way to check that TableRow.Height is changing?

How to prevent the change or set specific value?

Thank you.

 

Dimitar
Telerik team
 answered on 14 Jun 2023
1 answer
220 views

I want to create a RadFixedDocument with a table (see screenshot). Thereby the table is created dynamically:


Table headerTable = new Table();
            Telerik.Windows.Documents.Fixed.Model.Editing.Border headerBorder = new Telerik.Windows.Documents.Fixed.Model.Editing.Border(1, BorderStyle.Single, new RgbColor(217, 217, 217));
            headerTable.DefaultCellProperties.Borders = new TableCellBorders(headerBorder, headerBorder, headerBorder, headerBorder);
            headerTable.DefaultCellProperties.Padding = new Thickness(5, 10, 5, 10);

            TableRow headerRow = headerTable.Rows.AddTableRow();

            TableCell vacationEntitlementHeaderCell = headerRow.Cells.AddTableCell();
            vacationEntitlementHeaderCell.PreferredWidth = _maxWidth-100;
            vacationEntitlementHeaderCell.Background = new RgbColor(217, 217, 217);

            Block vacationEntitlementText = vacationEntitlementHeaderCell.Blocks.AddBlock();
            SetTextProperties(vacationEntitlementText, new RgbColor(0, 0, 0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217));
            vacationEntitlementText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
            vacationEntitlementText.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
            vacationEntitlementText.InsertText("Urlaubsanspruch: " + _localViewModel.Document.VacationEntitlement.ToString());

            TableCell vacationPlannedHeaderCell = headerRow.Cells.AddTableCell();
            vacationPlannedHeaderCell.PreferredWidth = _maxWidth-100;
            vacationPlannedHeaderCell.Background = new RgbColor(217, 217, 217);

            Block vacationPlannedText = vacationPlannedHeaderCell.Blocks.AddBlock();
            SetTextProperties(vacationPlannedText, new RgbColor(0, 0, 0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217));
            vacationPlannedText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
            vacationPlannedText.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
            vacationPlannedText.InsertText("Geplant: " + _localViewModel.Document.VacationDays.ToString());

            TableCell vacationFreeHeaderCell = headerRow.Cells.AddTableCell();
            vacationFreeHeaderCell.PreferredWidth = _maxWidth-100;
            vacationFreeHeaderCell.Background = new RgbColor(217, 217, 217);

            Block vacationFreeText = vacationFreeHeaderCell.Blocks.AddBlock();
            SetTextProperties(vacationFreeText, new RgbColor(0, 0, 0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217));
            vacationFreeText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
            vacationFreeText.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
            vacationFreeText.InsertText("Freie Urlaubstage: " + _localViewModel.Document.FreeVacationsDays.ToString());

            TableCell workTimeColorCell = headerRow.Cells.AddTableCell();
            workTimeColorCell.PreferredWidth = 150;
            workTimeColorCell.Background = new RgbColor(217, 217, 217);

            Block workTimeColorText = workTimeColorCell.Blocks.AddBlock();
            SetTextProperties(workTimeColorText, new RgbColor(85, 85, 85), 24, new FontFamily("Verdana"), new RgbColor(85, 85, 85));
            workTimeColorText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
            workTimeColorText.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
            workTimeColorText.InsertText(" ");

            TableCell WorkTimeHeaderCell = headerRow.Cells.AddTableCell();
            WorkTimeHeaderCell.PreferredWidth = _maxWidth;
            WorkTimeHeaderCell.Background = new RgbColor(217, 217, 217);

            Block workTimeText = WorkTimeHeaderCell.Blocks.AddBlock();
            SetTextProperties(workTimeText, new RgbColor(0,0,0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217));
            workTimeText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Left;
            workTimeText.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
            workTimeText.InsertText("Arbeitstage mit hinterlegter Sollarbeitszeit");

            _editor.Position.Translate(_defaultLeftIndent, 80);
            _editor.DrawBlock(headerTable, new Size(_maxWidth, double.PositiveInfinity));

            Table table = new Table();
            Telerik.Windows.Documents.Fixed.Model.Editing.Border border = new Telerik.Windows.Documents.Fixed.Model.Editing.Border(1, BorderStyle.Single, new RgbColor(204, 204, 204));
            table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);
            table.DefaultCellProperties.Padding = new Thickness(5, 10, 5, 10);

            TableRow valueHeaderRow = table.Rows.AddTableRow();
            TableCell monthCell = valueHeaderRow.Cells.AddTableCell();
            monthCell.PreferredWidth = 150;
            monthCell.Background = new RgbColor(217, 217, 217);

            Block month = monthCell.Blocks.AddBlock();
            SetTextProperties(month, new RgbColor(0, 0, 0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217), true);
            month.InsertText("Monat");

            for (int i = 1; i < 32; i++)
            {
                TableCell dayCell = valueHeaderRow.Cells.AddTableCell();
                dayCell.PreferredWidth = 50;
                dayCell.Background = new RgbColor(217, 217, 217);

                Block day = dayCell.Blocks.AddBlock();
                SetTextProperties(day, new RgbColor(0, 0, 0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217), true);
                day.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                day.InsertText(i.ToString());
            }

            foreach (var monthItem in _localViewModel.Document.Months)
            {
                TableRow monthRow = table.Rows.AddTableRow();
                TableRow appointmentRow = table.Rows.AddTableRow();
                
                TableCell monthHeaderCell = monthRow.Cells.AddTableCell();
                monthHeaderCell.PreferredWidth = 120;
                monthHeaderCell.Background = new RgbColor(217, 217, 217);
                monthHeaderCell.RowSpan = 2;

                Block monthName = monthHeaderCell.Blocks.AddBlock();
                SetTextProperties(monthName, new RgbColor(0, 0, 0), 12, new FontFamily("Verdana"), new RgbColor(217, 217, 217));
                monthName.VerticalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.VerticalAlignment.Center;
                monthName.InsertText(monthItem.Name);

                foreach (var dayItem in monthItem.Days)
                {
                    if (dayItem.Plan == 0)
                    {
                        RgbColor background = new RgbColor(255, 255, 255);
                        TableCell monthDayCell = monthRow.Cells.AddTableCell();
                        Block dayText = monthDayCell.Blocks.AddBlock();
                        monthDayCell.PreferredWidth = 50;

                        if (dayItem.Template == Templates.U)
                        {
                            background = new RgbColor(0, 153, 188);
                        }
                        monthDayCell.Background = background;

                        SetTextProperties(dayText, new RgbColor(0, 0, 0), 8, new FontFamily("Verdana"), background);
                        dayText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                        dayText.InsertText(dayItem.WeekdayStringShort.ToUpper());

                        TableCell appointmentDayCell = appointmentRow.Cells.AddTableCell();
                        //Block appointmentText = appointmentDayCell.Blocks.AddBlock();
                        appointmentDayCell.PreferredWidth = 50;
                        appointmentDayCell.Background = FormatAppointment(dayItem.Date);

                        //SetTextProperties(appointmentText, new RgbColor(0, 0, 0), 0, new FontFamily("Verdana"), new RgbColor(255, 255, 255));
                        //appointmentText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                        //appointmentText.InsertText(String.Empty);
                    }
                    else
                    {
                        TableCell monthDayCell = monthRow.Cells.AddTableCell();
                        RgbColor rgbColorBackground = new RgbColor(85, 85, 85);
                        RgbColor rgbColorForeground = new RgbColor(255, 255, 255);

                        monthDayCell.Background = rgbColorBackground;
                        Block dayText = monthDayCell.Blocks.AddBlock();
                        monthDayCell.PreferredWidth = 50;

                        SetTextProperties(dayText, rgbColorForeground, 8, new FontFamily("Verdana"), rgbColorBackground);
                        dayText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                        dayText.InsertText(dayItem.WeekdayStringShort.ToUpper());

                        TableCell appointmentDayCell = appointmentRow.Cells.AddTableCell();
                        //Block appointmentText = appointmentDayCell.Blocks.AddBlock();
                        appointmentDayCell.PreferredWidth = 50;
                        appointmentDayCell.Background = FormatAppointment(dayItem.Date);
                        
                        //SetTextProperties(appointmentText, new RgbColor(0, 0, 0), 0, new FontFamily("Verdana"), new RgbColor(255, 255, 255));
                        //appointmentText.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
                        //appointmentText.InsertText(String.Empty);
                    }
                }
            }
            
            _editor.Position.Translate(_defaultLeftIndent, 130);
            _editor.DrawBlock(table, new Size(_maxWidth, double.PositiveInfinity));
        }

How can I set the height of the empty row below each day?

Aleks
Telerik team
 answered on 12 Jun 2023
1 answer
152 views

Hello. I faced the problem when i am trying to get Route from BinRestMapProvider, using method CalculateRouteAsync, it returns status code 400 and message like this: "This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","errorDetails":["One or more parameters are not valid.","waypoint: One or more locations specified in the waypoint parameter are invalid or require more information. : 42,6957539183824;23,3327663758679"],"resourceSets":[],"statusCode":400,"statusDescription":"Bad Request" "

I just followed the example at:
https://docs.telerik.com/devtools/wpf/controls/radmap/features/providers/bing-rest-map-provider/routing

I guess problem is in example 4 of this doc: "request.Waypoints.Add(point.ToString());"

I hope someone can help me with it.

Dmytro
Top achievements
Rank 1
Iron
 answered on 09 Jun 2023
1 answer
375 views

Does the vulnerability that was in your MOVEit software also exist in the Telerik software?

Is it currently safe to download software from your website?

Lance | Senior Manager Technical Support
Telerik team
 answered on 06 Jun 2023
1 answer
168 views

I want to encrypt a zip archive.


using (FileStream stream = File.Create(Filepath + Filename))
 {
     DefaultEncryptionSettings encryptionSettings = new DefaultEncryptionSettings();
     encryptionSettings.Password = "123";

     using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, false, null, null, encryptionSettings))
     {
          using (ZipArchiveEntry entry = archive.CreateEntry("document.txt"))
          {
               StreamWriter writer = new StreamWriter(entry.Open());
               BinaryFormatter formatter = new BinaryFormatter();
               formatter.Serialize(writer.BaseStream, this);
          }
     }
}
When assigning a string directly for the password, the code works. If I assign the password via a string variable, the zip archive is not encrypted.

Aleks
Telerik team
 answered on 06 Jun 2023
1 answer
650 views

Hello,

After reading multiple questions in this forum regarding why the RadGridView is not refreshing when an existing item is updated, I am developing the refresh mechanism. I tried your suggest (calling CollectionChanged.Reset) but this solution is not good for us because when we call CollectionChanged the RadGridView is updated and also a lot of elements are drawn in a screen (thousand of elements and it cost a lot of performance).

So my solution is using a timer with refresh interval of 1 second which will refresh all the subscribed RadGridViews.

* I used WeakRefereces to avoid Memory Leaks.

In the distpatcher timer I do the following code:

if(radGridView == null || !radGridView.IsVisible) return;

var isRefreshRequired = radGridView.GroupDescriptors.Count >0 || radGridView.FilterDescriptors.Count>0 || radGridView.SortDescriptors.Count>0

if(isRefreshRequired)

{

   var collectionView = CollectionViewSource.GetDefaultView(radGridView.ItemSource);

   collectionView.Refresh?();

}

 

As mentioned, this code guarantees that only the view (RadGridView) is refresh and not the other elements of the SourceCollection.

I need your help with the following:

1. Only when there is a group and I scrolled down, after refresh the grid jumps to top (I couldn't reproduce when sorting or filter is enabled).

2. There is any good way to really know if the RadGridView is shown on screen (maybe it is visible but hidden in other tab), I need a method with fast access because I may check around 15 grids every second and I want to refresh only the required grids.

3. I tried to refresh the radGridView.Items instead of radGridViewItemsSource.
I expected this to work beause Items holds the items after grouping/filter/sorting. Unfortuneatly ,it doesn't work.

There is any way to refresh your internal view instead of the SourceCollection view that is bound to ItemSource?

The problem is that CollectionChanged on the view, triggers other code on my side that it will be good to skip for this case.

EDIT:

* I figured out that if I have a grid with 500 elements with two groups of 250 rows and one group is expanded then the application is almost freeze, the refresh is killing the performance. I think that my solution is better than Collection Reset so I don't know how to solve this :(

* Regarding point one, I think that the grid jumps because the Panel Unit is set to Content. I can't switch to Pixel because it will cause bad performance.

* I noticed that you have the method Reset for GroupDescriptors and SortDescriptors, the performance is the same. I taught that you maybe manage an internal caching and have some improvements there.

Vladimir Stoyanov
Telerik team
 answered on 05 Jun 2023
0 answers
171 views

I have tried to create two RadNumericUpDown controls, first one has a minimum value and second one has a maximum value. I thought that I can bind automatically minimum value as Minimum for second control, but here is the problem.

Problem is happens when Minimum value of RadNumericUpDown control was updated, but updated Value of second control was not bound to source.

<StackPanel>
        <telerik:RadNumericUpDown Value="{Binding MinValue, Mode=TwoWay}"/> //changes here are not updatind value of second control
        <telerik:RadNumericUpDown Value="{Binding MaxValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                  Minimum="{Binding MinValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>

 

 

Kostiantyn
Top achievements
Rank 1
Iron
 asked on 01 Jun 2023
1 answer
133 views

Sorry my bad English,

There is my RadGridView

<telerik:RadGridView x:Name="DepartmentBalanceListRadGridView"
                                     ItemsSource="{Binding Display}"
                                     IsBusy="{Binding IsBusy}"
                                     IsReadOnly="True"
                                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                                     AutoGenerateColumns="True"
                                     RowHeight="50"
                                     SelectionMode="Extended"
                                     CanUserFreezeColumns="False"
                                     RowIndicatorVisibility="Collapsed"
                                     GroupRenderMode="Nested"
                                     AutoExpandGroups="True"
                                     HorizontalAlignment="Stretch"
                                     VerticalAlignment="Stretch"
                                     VerticalGridLinesBrush="LightGray"
                                     ShowGroupFooters="True"
                                     ShowColumnFooters="True"
                                     CanUserResizeColumns="True"
                                     CanUserGroupColumns="False"
                                     ColumnWidth="*"
                                     AutoGeneratingColumn="DepartmentBalanceListRadGridView_AutoGeneratingColumn">

            <telerik:RadGridView.ControlPanelItems>
                <telerik:ControlPanelItem ButtonTooltip="Filtering Options">
                    <telerik:ControlPanelItem.ButtonContent>
                        <Button Background="Transparent">

                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Click">
                                    <cal:ActionMessage MethodName="PrintDepartmentBalance">
                                        <cal:Parameter Value="{Binding ElementName=DepartmentBalanceListRadGridView, Path=Items}"/>
                                        <cal:Parameter Value="{Binding ElementName=DepartmentBalanceListRadGridView, Path=SelectedItems}"/>
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>

                            <materialDesign:PackIcon Kind="Printer" Foreground="White" />

                        </Button>
                    </telerik:ControlPanelItem.ButtonContent>
                </telerik:ControlPanelItem>

            </telerik:RadGridView.ControlPanelItems>

            <telerik:RadGridView.Columns>

                <telerik:GridViewSelectColumn/>

            </telerik:RadGridView.Columns>

        </telerik:RadGridView>


Binding Display


private ObservableCollection<IDictionary<string, object>> _display;

public ObservableCollection<IDictionary<string, object>> Display
{
    get { return _display; }
    set
    {
         _display = value;
         NotifyOfPropertyChange(() => Display);
    }
}

now only 4 options 
is equal to, is not equal to, is null, is not null 

how can I add startswith and contains filter in the FilterControl ?

Martin Ivanov
Telerik team
 answered on 31 May 2023
0 answers
163 views

Hello, I have an issue with the style of the ContextMenus.

I changed the style of the ContextMenu and it is working for TextBlock and TextBox but on Telerik controls like RadNumericUpDown and RadRichTextBox the context menu looks different.

Let's take for example the menu in the RadNumericUpDown (see attached picture).

I expect that the menu with Cut,Copy,Paste looks like other menus.

I tried to define in RadNumericUpDown.Resources a style for ContextMenu and RadContextMenu (change the Background property) but it doesn't work.

When I change the Foreground property of the TextBlock style inside RadNumericUpDown.Resources, I can see that the text color changed.

I hope you can guide me on this matter.

Thanks,

Alex

alex
Top achievements
Rank 2
Bronze
Iron
Iron
 updated question on 29 May 2023
1 answer
381 views
I would like to know if the WPF RadDatePicker control offers a built-in clear button functionality to remove the selected date.
Martin Ivanov
Telerik team
 answered on 29 May 2023
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?