Telerik Forums
UI for WPF Forum
5 answers
254 views

I have a RadGridView. One of column is an Expander(Not RadExpander, just a regular WPF Expander). For some reason I want to get all Expanders. So by this solution.

private List<T> GetVisualTreeObjects<T>(DependencyObject obj) where T : DependencyObject
    {
        List<T> objects = new List<T>();
        int count = VisualTreeHelper.GetChildrenCount(obj);
        for (int i = 0; i < count; i++)
        {
            DependencyObject child = VisualTreeHelper.GetChild(obj, i);
            if (child != null)
            {
                T requestedType = child as T;
                if (requestedType != null)
                    objects.Add(requestedType);
                objects.AddRange(this.GetVisualTreeObjects<T>(child));
            }
        }
        return objects;
    }

I can get all Expanders by

var all = GetVisualTreeObjects<Expander>(this.grv);

Now I have a RadDataPager for this GridView,

<telerik:RadDataPager x:Name="radDataPager"
                          Source="{Binding Items, ElementName=radGridView}"
                          PageSize="5" />

if I switch to another page, in the PageIndexChanged event. I want to get the all expanders for the current page. But the result is always wrong.

Not sure why?

 

 

gg

Dilyan Traykov
Telerik team
 answered on 02 Mar 2018
3 answers
132 views

Hi,

I have an application using the telerik docking-framework and timelines. I have an issue when undocking a frame containing a RadTimeline.

I get a NullPointerException in Telerik.Windows.Controls.TimeBar.TimeIntervalContainerBase.RemoveDummyItem.

It turns out I only get the exception when I have the Intervals property set. If I remove the Intervals it does not crash.

I have another dockpanel with a RadTimeline as well, but that one does not generate the NullPointerException, so maybe I am doing something bad.

My RadTimeline xaml which crashes looks like this:

<telerik:RadTimeline
                MinHeight="55"
                Margin="2"
                AutoSort="False"
                DurationPath="Duration"
                GroupExpandMode="None"
                ItemsSource="{Binding TimePeriods}"
                PeriodEnd="{Binding VisiblePeriodEnd, Mode=OneWay}"
                PeriodHeaderStyle="{StaticResource PeriodHeaderStyle}"
                PeriodStart="{Binding VisiblePeriodStart, Mode=OneWay}"
                ScrollMode="None"
                SnapsToDevicePixels="True"
                StartPath="Start"
                TimelineItemTemplate="{StaticResource ItemTemplate}"
                VerticalScrollBarVisibility="Hidden"
                VisiblePeriodEnd="{Binding VisiblePeriodEnd, Mode=OneWay}"
                VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=OneWay}">
 
                <telerik:RadTimeline.Intervals>
                    <telerik:DayInterval FormatterProvider="{StaticResource DayFormatterProvider}" />
                </telerik:RadTimeline.Intervals>
 
            </telerik:RadTimeline>

 

Here is the callstack:

An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.Windows.Controls.DataVisualization.dll
Objektreferensen har inte angetts till en instans av ett objekt.
 
 
Ohanterat undantag: System.NullReferenceException: Objektreferensen har inte angetts till en instans av ett objekt.
   vid Telerik.Windows.Controls.TimeBar.TimeIntervalContainerBase.RemoveDummyItem()
   vid Telerik.Windows.Controls.TimeBar.TimeIntervalContainerBase.MeasureIntervalFormats()
   vid System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   vid System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   vid System.Windows.Threading.DispatcherOperation.InvokeImpl()
   vid MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   vid System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   vid System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   vid MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   vid System.Windows.Threading.DispatcherOperation.Invoke()
   vid System.Windows.Threading.Dispatcher.ProcessQueue()
   vid System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   vid MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   vid System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   vid System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   vid System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   vid MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   vid MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   vid System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   vid System.Windows.Application.RunDispatcher(Object ignore)
   vid System.Windows.Application.RunInternal(Window window)

 

Do you have any clue what is causing the issue?

 

Best regards

/Ola Nygren

Stefan
Telerik team
 answered on 02 Mar 2018
2 answers
100 views

Greetings,

I am currently working with a RadCartesianChart and I was wondering if it was possible to display a ScatterPointSeries with a CandleSticks instead of it's current data-point.  After reading the online documentation, I found out that I cannot use a CandlesticSeries since it requires a categorical axis for the X axis. Would it be doable to create a ScatterCandlesticSeries with the Telerik library?

 

Thank you and have a great day,

François

François
Top achievements
Rank 1
 answered on 01 Mar 2018
1 answer
542 views

I am trying to override the default behaviour for copy to clipboard from the PDF control when invoked from the keyboard.

I've created a class derived from FixedDocumentViewerCommandBase to add my custom action and this works when invoked from the Telerik toolbar or default context menu but it doesn't get invoked from the keyboard shortcut Ctrl-C.

So I've tried calling KeyBindings.Clear and adding a new KeyBinding.  At first, I thought this had not worked at all - the default copy to clipboard was executed when I selected some text.  However, what actually seems to be going on is that the KeyBindings are reset to their defaults when Mode is switched to TextSelection.

Have I missed a trick here?

Polya
Telerik team
 answered on 01 Mar 2018
2 answers
932 views

I've researched all morning how to modify the behavior of a RadGridView (in WPF) for moving focus from one control to the next, just like the Tab key does...  and like many other examples I've seen, I want to do the same thing: just make the Enter Key mimic the Tab key. But my code is not working.

If I have the following code in XAML:

                <telerik:GridViewDataColumn Name="MyColumn" CellStyleSelector="{DynamicResource MyColorStyle}" Width="64">
                    <telerik:GridViewDataColumn.Header>
                        <TextBlock Text="My Column" TextAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" />
                    </telerik:GridViewDataColumn.Header>
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding MyNumber}" TextAlignment="Right"></TextBlock>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewColumn.CellEditTemplate>
                        <DataTemplate>
                            <TextBox Name="MyNumberTextBox" Text="{Binding MyNumber, Mode=TwoWay}" IsTabStop="True" TabIndex="27" PreviewKeyDown="MyNumberTextBox_PreviewKeyDown" MaxLength="10" HorizontalAlignment="Stretch" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                        </DataTemplate>
                    </telerik:GridViewColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>

And I have this code in the code-behind:

private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
    if ((e.Key == Key.Enter) || (e.Key == Key.Return))
    {
        e.Handled = true;
        (sender as TextBox).MoveFocus(new TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
    }
}

 

The focus does not advance to the next column immediately to the right on the RadGridView row; it instead advances back to the top of the screen (to a pulldown menu control). I have TabStops explicitly set for every textbox in my column(s).

Could use some help here to determine what I am not doing properly, or what I may be missing. Thanks in advance for your help.

 

 

 

 

Barry
Top achievements
Rank 1
 answered on 28 Feb 2018
2 answers
1.6K+ views
Hi,
I'm trying to modify the navigation with the PreviewKeyDown event, but i need the current row index of the selected cell.

Second problem is to activate editing at the selected cell after this function:
        public static void SetSelectedCell(GridViewDataControl gridView, int row, int column)
        {
            gridView.SelectedItem = gridView.Items[row];
            gridView.ScrollIntoViewAsync(gridView.SelectedItem, gridView.Columns[column], (c) => c.Focus());

            //in addition focus grid to enable keyboard navigation(e.g. F2)
            gridView.Focus();
        }
Muhammd
Top achievements
Rank 1
 answered on 28 Feb 2018
8 answers
509 views

I set FormatString="n0" on RadMaskedTextInput and it works great when adding new digits. But it doesnot update its textbox value on delete.

For example, I enter 1 000 000, it looks OK, but when I remove last digit it becomes 1 000 00 , and what we expect is 100 000

I attached a screenshot which shows how it looks like on change

Is there a workaround available to fix this? 

 

Thanks

Best regards, 

Vladimid

 

Martin Ivanov
Telerik team
 answered on 27 Feb 2018
1 answer
109 views
Is there anyway to configure the GanttView component such that the timescales can be different for different date rages (see the attachment).   For example for the current year I want the lowest level to be months, for next year - quarters, and yearly after that.   Thanks in advance for any assistance with this.
Stefan
Telerik team
 answered on 27 Feb 2018
1 answer
79 views

I'm trying to modify the default behavior for expanding and contracting groups in the grid. End users (gotta love them) are complaining that it's too easy to inadvertently hide or show a group by clicking anywhere in the GroupHeaderRow. They want the group to be expanded or contracted based on clicking the glyph arrow on the far left of the GroupHeaderRow. I know I'm going to need to edit the Control Template, but just wondering if I could save some time by asking for specifics on what needs to be edited.

Thanks all.

Dilyan Traykov
Telerik team
 answered on 27 Feb 2018
7 answers
421 views

I want to repurpose the new item row to allow vertical editing of the grid, i.e. an edit in any cell of the new item row will be propagated down that column and the new item row's cell will be cleared after propagation to the other records.

  1. How can I keep the new item row in an editable state, removing the need to click the 'click here to add new item' placeholder
  2. Which events can I use to stop the new row addition, it seems I have to allow the addition then remove the row
  3. It would be nice to use a behavior for this (and not have to extend the grid), my other approach below is using a behavior and hooking the DataLoaded event to add the empty row

I have tried not using the new row and just adding an empty row to the data source but it doesn't play nice with descending sorting, however, most other operations seem to work ok on the minimal testing I have done. I think the new item row might be the more robust approach though.

 

Thanks,
Maurice

 

Stefan
Telerik team
 answered on 26 Feb 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?