Telerik Forums
UI for WPF Forum
0 answers
72 views

Good day. I have functionality in my WPF application that allows the user to change the font size, font style, and theme variations at runtime, see code below. This functions perfectly when it works. 

 

The issue I am having is that when making changes to these values at runtime, the changes intermittently stop being applied. The way I understand theming is that I should be able to make these changes at runtime and they are automatically applied. Something is getting borked up causing the changes to stop being applied during runtime.

 

C#, WPF .NET 6

Theme: Office 2019

Telerik Version: 2023.1.117

I'm using the package Telerik.UI.Wpf.NetCore.Xaml for all controls. Theme packages come from No XAML.

 

// Theme Color Variation// High Contrast
Office2019Palette.LoadPreset(Office2019Palette.ColorVariation.HighContrast);

// Dark/Light Mode
if (RegistryHelper.IsWindowsDarkMode())
    Office2019Palette.LoadPreset(Office2019Palette.ColorVariation.Dark);
else
    Office2019Palette.LoadPreset(Office2019Palette.ColorVariation.Light);


// Change Font Family
Office2019Palette.Palette.FontFamily = new FontFamily(Settings.Default.FontFamily);


// Font Size
Telerik.Windows.Controls.Office2019Palette.Palette.FontSizeS = 10;
Telerik.Windows.Controls.Office2019Palette.Palette.FontSize = 12;
Telerik.Windows.Controls.Office2019Palette.Palette.FontSizeL = 14;

 

App.xaml for Telerik:

<prism:PrismApplication x:Class="Wpf.App"
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                        xmlns:prism="http://prismlibrary.com/">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>

                <!-- Telerik -->
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/System.Windows.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/Telerik.Windows.Controls.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/Telerik.Windows.Controls.Input.xaml" />
                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2019;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</prism:PrismApplication>

 

Justin
Top achievements
Rank 2
Iron
 updated question on 20 Sep 2023
1 answer
97 views

Our organization has an app that we're porting from .NET/WPF to React. We have several grids, that utilize this:

```

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Telerik.WinControls;
using System.Configuration;
using System.Data.SqlClient;
using Telerik.WinControls.UI;
using Telerik.WinControls.Data;
using System.Data.OleDb;
using System.Linq;
using System.Threading.Tasks;
using System.Web.UI.WebControls;

using System.ComponentModel;

```

Instead, I'd like to use KendoReact.

Before I rewrite the entire thing in NextJS/KendoReact, are there some tools and techniques that I could use to save time?

Martin Ivanov
Telerik team
 answered on 15 Sep 2023
0 answers
32 views

Sometimes when I paste a test intro en empty RadMaskedTextInput, the application crushes and the following error occurs:

 

FATAL Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

                at System.Text.StringBuilder.Remove(Int32 startIndex, Int32 length)

   at Telerik.Windows.Controls.RadMaskedTextInput.HandlePasteNoMask(Object value, Object& returnString)

   at Telerik.Windows.Controls.RadMaskedTextInput.HandlePasteOverride(Object value, Object& returnString)

   at Telerik.Windows.Controls.RadMaskedInputBase.HandlePaste()

   at Telerik.Windows.Controls.RadMaskedInputBase.OnApplicationPaste(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)

   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)

   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)

   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

  at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)

   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)

   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)

   at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)

   at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)

   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)

   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

   at System.Windows.Input.InputManager.ProcessStagingArea()

   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)

   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)

   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)

   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)

   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)

   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)


1 answer
56 views

Hi,

I'm looking for some advice on the best control to use for user input of a single element, though drag&drop , that also has data validation display.

I have used it on RadListBox, RadGridView and RadTreeView but in this case I do not have a collection to fill.

I would like for the control to bind to a single property of type Foo and use the DragDropManager / BeahviorManager / PayloadManager to control what can be dragged / dropped onto the control so that the bound variable is updated.

I would also like for the control to display any validation error through INotifyDataErrorInfo

I would appreciate any suggestions.

 

Thank you for your help.

 

 

 

Martin Ivanov
Telerik team
 answered on 14 Aug 2023
1 answer
49 views

Hi,

I tried to upgrade my app which have a reference to telerik.windows.Documents.for.WPF.

It seems that it is not supported for .NET 7. (only .NET Framework).

Will it be supported ?

 

Thank's for your response.

Dimitar
Telerik team
 answered on 07 Aug 2023
1 answer
90 views

With every new release, we recompile the libraries so that we can set the application name to meet licensing requirements.

However, with 2023 R3, the compilation is failing due to four instances of a call to FunctionBase.LinearInterpolate in BrushRenderer.cs which leads to the following compilation error:

Fixed\UI\BrushRenderer.cs(233,50): error CS0117: 'Telerik.Windows.Documents.Fixed.Model.Common.Functions.FunctionBase' does not contain a definition for 'LinearInterpolate'

The LinearInterpolate method is definitely not defined in FunctionBase, would appreciate any available help on this.

 

Fixed\UI\BrushRenderer.cs(233,50): error CS0117: 'Telerik.Windows.Documents.Fixed.Model.Common.Functions.FunctionBase' does not contain a definition for 'LinearInterpolate' [C:\agent\_work\13\s\Source\Controls\PdfViewer\FixedDocumentViewers\Telerik.Windows.Controls.FixedDocumentViewers_WPF.csproj] [C:\agent\_work\13\s\Source\Build\BuildControls.proj]
Fixed\UI\BrushRenderer.cs(233,50): error CS0117: 'Telerik.Windows.Documents.Fixed.Model.Common.Functions.FunctionBase' does not contain a definition for 'LinearInterpolate' [C:\agent\_work\13\s\Source\Controls\PdfViewer\FixedDocumentViewers\Telerik.Windows.Controls.FixedDocumentViewers_WPF.csproj] [C:\agent\_work\13\s\Source\Build\BuildControls.proj]
Martin Ivanov
Telerik team
 answered on 28 Jul 2023
1 answer
126 views

For a home project I'm working on, I have paid upto version R3 2021 SP2.  Will this version work with Visual Studio 2022 and can I use .NET 7 with this version?

If not, what is the most current version of Telerik UI WPF that does support Visual Studio 2022?

What is the most current version of Telerik UI WPF that supports .NET 7?

Thanks, Rob.

Martin Ivanov
Telerik team
 answered on 24 Jul 2023
0 answers
73 views

I think that this is a general question: I have a RadDocking with document host. Generally I can load many tab inside the panel, every tab has his viewmodel that it is an instance of the same class.
When I binding a control property to a viewmodel property I need to bind it to the correct instance.
Now I use binding in code behind using a variable index such as 

pane.SetBinding(RadPane.HeaderProperty, new Binding()
{
    Path = new($"MainVM.Partitions[{_vm.MainVM.PartitionAttiva.Partition.Id}])
});
Is not important the meaning of pieces, the important is the dynamic index that stand for the tab index.

My question is if is there a more standard method to achieve this goal
Thank you 
Luigi
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
 asked on 28 Jun 2023
1 answer
67 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
53 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?