Telerik Forums
UI for WPF Forum
1 answer
17 views
I am using telerik's RadGridView as my datagrid and I want to make the search disabled when a toggle button is switched, the things I want are like so:
- When the user unchecks the toggle the search should clear and the user will still be able to type the searchbar but it will not execute any search 
- when the user checks the toggle if there is a text in the searchbar, the search will be executed based on that text and the user will be able to seach from now on

I tried this:
 private string searchText { get; set; }
 private void MainDatagrid_Searching(object sender, GridViewSearchingEventArgs e)
 {
     if (!(bool)showFilteredToggleButton.IsChecked)
     {
         e.Cancel = true;
         searchText = e.SearchText;
     }
     else
     {
         e.Cancel = false;
         searchText = e.SearchText;
     }
 }

 private void showFilteredToggleButton_Checked(object sender, RoutedEventArgs e)
 {
     if (!(bool)showFilteredToggleButton.IsChecked)
     {
         var clearSearchValue = GridViewSearchPanelCommands.ClearSearchValue as RoutedUICommand;
         clearSearchValue.Execute(null, MainDatagrid.ChildrenOfType<GridViewSearchPanel>().FirstOrDefault());
     }
     else
     {
         var searchBytextCommand = RadGridViewCommands.SearchByText as RoutedUICommand;
         searchBytextCommand.Execute(searchText, MainDatagrid);
     }
 }

But there are some features missing such as when user checks the toggle the search isn't initiated and when the user unchecks the toggle the searchbar clears itself but the search isn't cleared, old search remains. How can achieve the functionality I described? Can you help me?
Dimitar
Telerik team
 answered on 27 Mar 2024
0 answers
23 views

We recently updated to version 2024.1.312.  After the update, we get an exception (see stack trace below) or freezing with many of our RadToggleSwitchButtons.  It seems to only affect the ones that are backstage in a RadDataForm.  I found https://feedback.telerik.com/wpf/1645011-buttons-nullreferenceexception-when-setting-ischecked-of-radtoggleswitchbutton-before-the-control-is-added-to-the-visual-tree, but the workaround suggested there doesn't work for us, even if we leave the animations enabled.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Telerik.Windows.Controls
  StackTrace:
   at Telerik.Windows.Controls.RadToggleSwitchButton.OnIsCheckedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.PropertyChangedCallback.Invoke(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.StyleHelper.ApplyTemplatedParentValue(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, DependencyProperty dp, FrameworkElementFactory templateRoot)
   at System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory templateRoot)
   at System.Windows.FrameworkTemplate.InvalidatePropertiesOnTemplate(DependencyObject container, Object currentObject)
   at System.Windows.FrameworkTemplate.HandleBeforeProperties(Object createdObject, DependencyObject& rootObject, DependencyObject container, FrameworkElement feContainer, INameScope nameScope)
   at System.Windows.FrameworkTemplate.<>c__DisplayClass45_0.<LoadOptimizedTemplateContent>b__2(Object sender, XamlObjectEventArgs args)
   at System.Xaml.XamlObjectWriter.OnBeforeProperties(Object value)
   at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
   at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
   at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
   at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
   at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
   at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)
   at System.Windows.FrameworkElement.ApplyTemplate()
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.StackPanel.StackMeasureHelper(IStackMeasure measureElement, IStackMeasureScrollData scrollData, Size constraint)
   at System.Windows.Controls.StackPanel.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.ItemsPresenter.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.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   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.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   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)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   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)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()

 

Jennifer
Top achievements
Rank 1
Iron
 updated question on 26 Mar 2024
2 answers
36 views

I'm using a VirtualizingWrapPanel as the ItemsPanelTemplate of a RadListBox

<telerik:RadListBox x:Name="ItemControl"
                    Grid.Row="1"
                    VirtualizingPanel.ScrollUnit="Pixel"
                    ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UserControl}}, Path=PathName}">

    <telerik:RadListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <telerik:VirtualizingWrapPanel HorizontalAlignment="Center" ItemWidth="200" ItemHeight="180"/>
        </ItemsPanelTemplate>
    </telerik:RadListBox.ItemsPanel>

The ItemsSource is a ListCollectionView which is Live updating 

 


ListCollectionView = new(Models);
ListCollectionView.IsLiveSorting = true;

ListCollectionView.SortDescriptions.Add(new SortDescription("Percentage", ListSortDirection.Ascending));

The collection seems to be updating and reaching the UI; however, every so often I get empty cells in the RadListBox after a sorting happens.


If I scroll away and come back the area is filled in. Is there something I can do manually so that this area is filled in? Should I try reloading something in some way?

 

I've tried invalidating things in the wrap panel but this hasn't worked:

wrapPanel?.InvalidateArrange();
wrapPanel?.InvalidateMeasure();
wrapPanel?.InvalidateVisual();
wrapPanel?.UpdateLayout();

 

Any help or suggestions are appreciated

Martin Ivanov
Telerik team
 answered on 26 Mar 2024
1 answer
19 views

We would like to change the color of the highlighted items (i.e., HighlightedItemsSource) in the RadGanttView.

I know this is possible by copying and customizing the ControlTemplate, but I would like to avoid that if possible since I would need to do that for all the different types of containers.

I also know it's possible to change the color in the theme (we're using Office2019), but unfortunately, the template uses ValidationBrush for these highlights and we still want the validation to show as red in other areas of our application.

Is there any other way to change the color of the highlighted items?

Stenly
Telerik team
 answered on 26 Mar 2024
1 answer
30 views

If I have set the Angle Range on a RadPieChart so that I have a semicircle, is there a good way to make the remaining chart take up the entire area used for the RadPieChart or at least a good way to center it?


<telerik:RadPieChart x:Name="Chart" Background="Yellow">

    <telerik:RadPieChart.Series>

        <telerik:DoughnutSeries x:Name="DonutSeries" ShowLabels="False">

            <telerik:DoughnutSeries.DataPoints>
                <telerik:PieDataPoint Label="TestLabel1" Value="15"/>
                <telerik:PieDataPoint Label="TestLabel2" Value="50"/>
            </telerik:DoughnutSeries.DataPoints>

            <telerik:DoughnutSeries.LegendSettings>
                <telerik:DataPointLegendSettings TitleBinding="Label"/>
            </telerik:DoughnutSeries.LegendSettings>

            <telerik:DoughnutSeries.AngleRange>
                <telerik:AngleRange StartAngle="180" SweepAngle="180" SweepDirection="Clockwise"/>
            </telerik:DoughnutSeries.AngleRange>

        </telerik:DoughnutSeries>


    </telerik:RadPieChart.Series>
</telerik:RadPieChart>

 

Thank You!

Dimitar
Telerik team
 answered on 25 Mar 2024
1 answer
21 views

Hello,

I'm using a RadMaskedTextInput and I'm wondering if it's possible to change the foreground color of just the placeholders?

What I'm trying to accomplish is for every X in below image to appear in a brighter color than the text typed in by the user.

What my RadMaskedTextInput looks like currently:

What I want the foreground to look like:

Stenly
Telerik team
 answered on 25 Mar 2024
2 answers
22 views

Is there a way to use RadGlyphs as icons for the items of a RadBreadcrumb?

Thank you.

Wizard6650
Top achievements
Rank 1
Iron
 updated answer on 25 Mar 2024
0 answers
22 views

Hi,

I am trying to change the theme through telerik StyleManager.Theme.

Not apply :

 <mynumeric:MyNumeric x:Name="TEST" Margin="-2,0,0,0"
                  Value="{Binding ViewModel.SerialNumber,Mode=TwoWay}" 
                   ValueFormat="Numeric"
                   NumberDecimalDigits="0"
                   Minimum="1" Maximum="9999"
                   telerik:StyleManager.Theme="{Binding Path=(mainwindowviewmodel:MainWindowViewModel.CurrentTheme),Converter={StaticResource ThemeToTelerikThemeConverter}}"
                   IsReadOnly="{Binding Path=(mainwindowviewmodel:MainWindowViewModel.IsManagerAccess),Converter={StaticResource InverseBooleanConverter}}"
                   >

Apply :

 <telerik:RadNumericUpDown x:Name="TEST" Margin="-2,0,0,0"
                  Value="{Binding ViewModel.SerialNumber,Mode=TwoWay}" 
                   ValueFormat="Numeric"
                   NumberDecimalDigits="0"
                   Minimum="1" Maximum="9999"
                   telerik:StyleManager.Theme="{Binding Path=(mainwindowviewmodel:MainWindowViewModel.CurrentTheme),Converter={StaticResource ThemeToTelerikThemeConverter}}"
                   IsReadOnly="{Binding Path=(mainwindowviewmodel:MainWindowViewModel.IsManagerAccess),Converter={StaticResource InverseBooleanConverter}}"
                   >

public class MyNumeric : RadNumericUpDown
{
    public override string FormatDisplay()
    {
        if (this.Value.HasValue)
        {
            return this.Value.Value.ToString("0000");
        }
        return base.FormatDisplay();
    }

    public override string FormatEdit()
    {
        if (this.Value.HasValue)
        {
            return this.Value.Value.ToString("0000");
        }
        return base.FormatEdit();
    }
}

internal class ThemeToTelerikThemeConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (!Enum.IsDefined(typeof(Wpf.Ui.Appearance.ThemeType), value))
            throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum");

        switch (value)
        {
            case Wpf.Ui.Appearance.ThemeType.Light:
                return "Office2019";
            case Wpf.Ui.Appearance.ThemeType.Dark:
                return "Expression_Dark";

            default:
                return "Office2019";
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

I'll appreciate any help.

 

Dooly
Top achievements
Rank 1
Iron
 asked on 25 Mar 2024
1 answer
17 views

Hello,

            I want to update the node and connector after giving the GraphDatasource in the "RadDiagram", 

           Because I want to used different nodes and different style connectors together in diagram.

            

 

Martin Ivanov
Telerik team
 answered on 22 Mar 2024
1 answer
17 views

I have to scrub pasted fragments from web sources to remove any hyperlinks in those fragments but keep the text associated with the link if any.  I have tried the following code which gets the proper hyperlink elements, but this is not removing the hyperlink info.   Please let me know the proper method of finding all hyperlinks in the pasted document content and removing those links.  Thanks.


            var richTextBox = new RadRichTextBox();
            richTextBox.InsertFragment(document.Selection.CopySelectedDocumentElements());
            richTextBox.Document.Selection.SelectAll();

            var boxes = richTextBox.Document.Selection.GetSelectedBoxes().Where(b => b.AssociatedInline.FieldStart != null && b.AssociatedInline.FieldStart.GetType() == typeof(HyperlinkRangeStart));
            foreach (var box in boxes)
            {
                richTextBox.Document.CaretPosition.MoveToInline(box.AssociatedInline);
                richTextBox.RemoveHyperlink();
            }

Dimitar
Telerik team
 answered on 22 Mar 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?