Telerik Forums
UI for WPF Forum
3 answers
342 views
I have this project where the software communicates with a remote hardware.
Based on the visible rows, I need to read only the visible section inside a buffer in the hardware and update the grid accordingly (this is to prevent reading load of irrelevant data which is currently not visible to the user).
There is no easy way of telling what are the visible rows in the GridView (I have read that there was, but now we have to dig in).

I have tried using the method in the example that was given here:
http://www.telerik.com/community/forums/wpf/gridview/firstvisiblechildindex.aspx

However, for some reason in my project it will never find the last row, therefore causing an exception.

I have used a different method of getting all the rows from the virtualizing stack panel and then iterating them to see what is the lowest item index and using the rows count at the num of rows:

        private void recalculateFirstAndLastVisibleIndexes()
        {
            var gvvp = this.radGridView.ChildrenOfType<GridViewVirtualizingPanel>().FirstOrDefault();
 
            if (gvvp == null)
                return;
 
            var rowsList = gvvp.ChildrenOfType<GridViewRow>();
 
            if (rowsList.Any())
            {
                int firstIndex = this.radGridView.Items.IndexOf(rowsList.ElementAt(0).Item);
                foreach (var row in rowsList)
                {
                    firstIndex = Math.Min(firstIndex, this.radGridView.Items.IndexOf(row.Item));
                }
 
                FirstVisibleRowIndex = firstIndex;
                NumOfVisibleRows = rowsList.Count();
            }
            else
            {
                FirstVisibleRowIndex = 0;
                NumOfVisibleRows = 0;
            }
        }



This does work (although it seems to return a little more rows than expected when the scrollviewer is visible....


Still, when the UI starts I try getting the visible rows on several occasions:
radGridView_Loaded
radGridView_DataLoaded
and also: radGridView_ScrollChanged

The problem is that it is not enough...
When I get the DataLoaded event, the rowsList is still empty... I need to wait for the next LayoutUpdated event and only then call the recalculateFirstAndLastVisibleIndexes function.

If I try to rely only on the ScrollChanged event then if there are for example 10 rows and the window are can contain 20 row, then if I add or remove rows then this event is never being called.


I did not find any way to get notified when the visible rows change. Is there any solution?

Thanks.
Vlad
Telerik team
 answered on 20 Nov 2012
1 answer
123 views
I get the following error when trying to view the Grid demo:

The database 'C:\PROGRAM FILES (X86)\TELERIK\RADCONTROLS FOR ASP.NET AJAX Q3 2012\LIVE DEMOS\APP_DATA\NORTHWIND.MDF' cannot be opened because it is version 655. This server supports version 612 and earlier. A downgrade path is not supported.
Could not open new database 'C:\PROGRAM FILES (X86)\TELERIK\RADCONTROLS FOR ASP.NET AJAX Q3 2012\LIVE DEMOS\APP_DATA\NORTHWIND.MDF'. CREATE DATABASE is aborted.
An attempt to attach an auto-named database for file C:\Program Files (x86)\Telerik\RadControls for ASP.NET AJAX Q3 2012\Live Demos\App_Data\Northwind.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.



Please advise
Vlad
Telerik team
 answered on 20 Nov 2012
9 answers
640 views
Hi,

I want to use the Telerik grid to show a read only live feed of millions of records (while still supporting sorting, filtering, etc.).
Is it supported (I will also want to use the DataFilter to filter the live feed)? 

I have two questions:
1. I went over the documentation and couldn't find any performance guidance on how to populate the grid with millions of records of live data.
Should I feed the grid one row at a time by adding it to the Items collection? 
Should I use ObservableCollection and add rows to it when they are available?
Should I add single rows or should I add batches of rows?
If I'm using an ObservableCollection, I can't add records to it from a worker thread. I need to use the Dispatcher to actually feed the collection, which seems to slow down everything... What is the right way to do so?
I tried implementing the ObservableCollection approach, adding 3000 rows every second (while using the Dispacher and DeferRefresh), but it is a bit slow and not so responsive. 

2. When implementing the ObservableCollection and the Dispatcher, I noticed a strange scrolling issue. Every time there is an update (adding rows to the collection) the grid scrolls back to the first row.
I actually want a different behavior and I can't figure out how to do that.
I want the grid to automatically scroll to the last row, but if the user is manually scrolling, I want the automatic scrolling to stop and the grid to stay where the user scrolled to.
I can probably implement the auto scrolling myself, but I can't find how to tell the grid not to scroll to the first line. How can I do that?

Thank you,
Yoav.
Pavel Pavlov
Telerik team
 answered on 19 Nov 2012
1 answer
1.0K+ views
How can I implement blur in MainWindow when I opened ModalWindow?
See attached file. Tnank You.
Boyan
Telerik team
 answered on 19 Nov 2012
1 answer
859 views

Hello, I have got Window with modalWindow.
I face issue.
When I am opening the modal window and after clicking on iconApp on taskbar, modal window is disappears and I can't do anything with my app (only end app in task manager). See attached files

 


I created the mainWindow by this way.
<t:RadWindow
    xmlns:n="clr-namespace:Telerik.Windows.Controls.Navigation;assembly=Telerik.Windows.Controls.Navigation"
    n:RadWindowInteropHelper.ShowInTaskbar="True"   
    x:Class="SOme.Some.MainWindow"
    t:StyleManager.Theme="Metro"
    MinHeight="480" MinWidth="800" Height="650" Width="1024"
    WindowStartupLocation="CenterScreen"
    xmlns:vm="clr-namespace:someName">
 
.....
</t:RadWindow>
in CS code I call method as

var mainWindow = new MainWindow();
mainWindow.Show();

I created a modal window in exactly the same way.
<t:RadWindow x:Class="Some.Some.SomeWindow"
             xmlns:t="http://schemas.telerik.com/2008/xaml/presentation"
             t:StyleManager.Theme="Metro"
             WindowStartupLocation="CenterScreen"
             CanMove="False"
             CanClose="False"
             ResizeMode="NoResize"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    ...
</t:RadWindow>

and call following method
var mainWindow = new NewClientWindow();
mainWindow.ShowDialog();

I'm doing something wrong or this is a bug?
Thank you.


I use the following code to show the icon in the system tray (taskbar).
xmlns:n="clr-namespace:Telerik.Windows.Controls.Navigation;assembly=Telerik.Windows.Controls.Navigation"
 
    n:RadWindowInteropHelper.ShowInTaskbar="True"
Is there any best way?
Boyan
Telerik team
 answered on 19 Nov 2012
1 answer
209 views
I am binding a RadSparkline against an INotifyCollectionChanged object. This object is NOT an ObservableCollection<>. It is raising CollectionChanged, with Action: Add, with StartingIndex as -1. This should be allowed when the collection is unordered, as mine is. However, RadSparkline is throwing an exception:

ArgumentOutOfRangeException Index must be within the bounds of the List.
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.Insert(Int32 index, T item)
   at Telerik.Windows.Controls.ProjectedView`1.ObservableSourceListCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) in c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\DataVisualization\Common\DataProjection\ProjectedView.cs:line 179

I am going to solve this problem by making a temporary ObservableCollection, and adding new items to the end of it as they arrive. However, this should not be required.
Tsvetie
Telerik team
 answered on 19 Nov 2012
3 answers
159 views
Hi
I would like to use a single property grid to present a class that is selectable by a user. Also, I want to control what properties are presented for each class. To be more specific, I have currently five tables in SQL Server that are mapped using OpenAccessORM. In the future the number of tables may increase so I would only want to update the entity model component. I want the user to be able to select which table they want to view in the propertygrid and I also want to limit the columns of each table that are presented in the propertygrid.

With regards to the subset of properties, is there a way to use AutogeneratePropertyDefinitions="True" for a subset of columns? If not, would I have to add the property definitions I want to present in code rather than XAML?

To be able to use a single property grid, would I need to use DynamicObject?

I'm using RadControls Q3 (2012.03.1017) and OpenaccessORM Q3 (2012.03.1012).

Regards
Craig

Ivan Ivanov
Telerik team
 answered on 19 Nov 2012
1 answer
141 views

Dear Telerik Team!

I use custom appointment which inherits from EntityObject. What I want to achieve is to place a button on an appointment, so I placed following code on the custom appointment template:

<Button Grid.Column="0" Grid.Row="1" Content="{Binding Appointment.Approved}" Width="50" Height="50" prism:Click.CommandParameter="{Binding Appointment.Id}" prism:Click.Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.TaskApprovalCommand}" />

I'm able to click the button and execute its command, but when I change "Approved" property the UI is not updating. When I try to bind the content of the button to some other property, like "Subject" it is working fine. The problem is with custom properties, the ones which are not part of original appointment class. Could you please suggest some solution for that problem? I'd be very grateful.

Many thanks and best regards
Krzysztof Kaźmierczak

Yana
Telerik team
 answered on 19 Nov 2012
5 answers
191 views

Hi,

I'm using Telerik RadControls Q3 2012. After the update, I plan to add a Bollinger Band to a ChartView. However, after several trials, it always hangs the application by System.NullReferenceException: Object reference not set to an instance of an object.

The ChartView I'm using is a simple LineSeries chart in XAML:

<telerik:RadCartesianChart Margin="5" Grid.Column="0" x:Name="PriceChart" Padding="0,0,0,0">
                    <telerik:RadCartesianChart.HorizontalAxis>
                        <telerik:DateTimeContinuousAxis LabelFormat="d-MMM-yy"
                                                                MajorStep="1"
                                                                MajorStepUnit="Month"                                                               
                                                                GapLength="0.8"
                                                                PlotMode="OnTicks"                                                               
                                                                />
                    </telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:RadCartesianChart.VerticalAxis>
                        <telerik:LinearAxis BorderBrush="DimGray" BorderThickness="0.5" />
                    </telerik:RadCartesianChart.VerticalAxis>
                    <telerik:RadCartesianChart.Series>
                        <chartView:LineSeries ItemsSource="{Binding ChartData}"
                                              CategoryBinding="Date"
                                              ValueBinding="Price" 
                                              Stroke="Black"
                                              StrokeThickness="0.5"/>                       
                    </telerik:RadCartesianChart.Series>
                    <telerik:RadCartesianChart.Grid>
                        <telerik:CartesianChartGrid MajorLinesVisibility="Y"/>
                    </telerik:RadCartesianChart.Grid>
                </telerik:RadCartesianChart>




This is how I add the Bollinger Band to the chart:

 

LineSeries lineSeries = this.PriceChart.Series[0] as LineSeries;
                if ((lineSeries != null) && (lineSeries.ItemsSource != null))
                {
                    BollingerBandsIndicator indicator = new BollingerBandsIndicator();
                    indicator.Period = 5;
                    indicator.StandardDeviations = 2;
                    indicator.CategoryBinding = lineSeries.CategoryBinding;
                    indicator.ValueBinding = lineSeries.ValueBinding;
                    indicator.ItemsSource = lineSeries.ItemsSource;
 
                    indicator.Stroke = Brushes.Red;
                    indicator.LowerBandStroke = Brushes.Red;
                    indicator.StrokeThickness = 1;
 
                    this.PriceChart.Indicators.Add(indicator);
                }

 

 

 



And this is the StackTrace for the Exception caught:
  

at
Telerik.Windows.Controls.ChartView.BollingerBandsIndicatorDataSource.BindCore()
in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\DataBinding\DataSources\Financial\BollingerBandsIndicatorDataSource.cs:line
63<BR>   at
Telerik.Windows.Controls.ChartView.ChartSeriesDataSource.Bind() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\DataBinding\DataSources\ChartSeriesDataSource.cs:line
235<BR>   at
Telerik.Windows.Controls.ChartView.ChartSeriesDataSource.Rebind(Boolean
itemsSourceChanged, IEnumerable newSource) in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\DataBinding\DataSources\ChartSeriesDataSource.cs:line
81<BR>   at
Telerik.Windows.Controls.ChartView.ChartSeriesDataSource.set_ItemsSource(IEnumerable
value) in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\DataBinding\DataSources\ChartSeriesDataSource.cs:line
54<BR>   at
Telerik.Windows.Controls.ChartView.ChartSeries.InitDataBinding() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Common\ChartSeries.cs:line
316<BR>   at
Telerik.Windows.Controls.ChartView.IndicatorBase.InitDataBinding() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\Indicators\IndicatorBase.cs:line
94<BR>   at
Telerik.Windows.Controls.ChartView.ValueIndicatorBase.InitDataBinding() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\Indicators\ValueIndicatorBase.cs:line
50<BR>   at
Telerik.Windows.Controls.ChartView.ChartSeries.OnApplyTemplate() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Common\ChartSeries.cs:line
239<BR>   at
Telerik.Windows.Controls.ChartView.LineIndicatorBase.OnApplyTemplate() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\Indicators\LineIndicatorBase.cs:line
112<BR>   at
Telerik.Windows.Controls.ChartView.BollingerBandsIndicator.OnApplyTemplate() in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\CartesianChart\Indicators\BollingerBandsIndicator.cs:line
125<BR>   at
System.Windows.FrameworkElement.ApplyTemplate()<BR>   at
Telerik.Windows.Controls.ChartView.RadChartBase.OnPresenterAdded(ChartElementPresenter
presenter) in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\RadChartBase.cs:line
405<BR>   at
Telerik.Windows.Controls.ChartView.PresenterCollection`1.InsertItem(Int32 index,
T item) in
c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Controls\Chart\Visualization\Common\PresenterCollection.cs:line
34<BR>   at
STA.Modules.MarketData.Views.PairAnalytics.PairAnalyticsDetailPairView.<PostQueryChartData>b__0()
in C:\Segantii\Development\Source Control\Projects\Odin\trunk\Source
Codes\SegantiiTradingAnalytics\STA.Modules.MarketData\Views\PairAnalytics\PairAnalyticsDetailPairView.xaml.cs:line
70<BR>   at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,
Object args, Int32 numArgs)<BR>   at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate
method, Object args, Int32 numArgs, Delegate catchHandler)<BR>   at
System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object
args, Int32 numArgs, Delegate catchHandler)<BR>   at
System.Windows.Threading.DispatcherOperation.InvokeImpl()<BR>   at
System.Threading.ExecutionContext.runTryCode(Object userData)<BR>   at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)<BR>   at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean ignoreSyncCtx)<BR>  
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)<BR>   at
System.Windows.Threading.DispatcherOperation.Invoke()<BR>   at
System.Windows.Threading.Dispatcher.ProcessQueue()<BR>   at
System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam, Boolean& handled)<BR>   at
MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr
lParam, Boolean& handled)<BR>   at
MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)<BR>   at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,
Object args, Int32 numArgs)<BR>   at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate
method, Object args, Int32 numArgs, Delegate catchHandler)<BR>   at
System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object
args, Int32 numArgs, Delegate catchHandler)<BR>   at
System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority,
TimeSpan timeout, Delegate method, Object args, Int32 numArgs)<BR>  
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam)<BR>   at
MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)<BR>   at
System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame
frame)<BR>   at System.Windows.Application.RunInternal(Window
window)<BR>   at System.Windows.Application.Run()<BR>   at
SegantiiTradingAnalytics.App.Main() in C:\Segantii\Development\Source
Control\Projects\Odin\trunk\Source
Codes\SegantiiTradingAnalytics\SegantiiTradingAnalytics\obj\x86\Debug\App.g.cs:line
0<BR>   at System.AppDomain._nExecuteAssembly(RuntimeAssembly
assembly, String[] args)<BR>   at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext, String[] activationCustomData)<BR>   at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()<BR>  
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean ignoreSyncCtx)<BR>  
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)<BR>   at
System.Threading.ThreadHelper.ThreadStart()

Any help will be welcome.
Many thanks!

Frankie


Petar Marchev
Telerik team
 answered on 19 Nov 2012
2 answers
152 views
Hi!

I've tried to add a custom function to the functions list and haven'd found any way to do it. In Win Forms, this is possible by extending
Telerik.Data.Expressions.ExpressionContext
class. However, in WPF i haven't found any similar class.
Can you help, please?
Alex
Alexandru
Top achievements
Rank 1
 answered on 19 Nov 2012
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?