or
public class VirtualQueryableCollectionViewHelper<T> where T : Entity{ public IEventAggregator EventAggregator { get; set; } public VirtualQueryableCollectionViewHelper(Func<QueryableXenoxContext, EntityQuery<T>> queryGenerator, queryableXenoxContext queryableXenoxContext, XenoxGridView gridView) { EventAggregator = ClientIocContainer.Instance.GetExportedValue<IEventAggregator>(); QueryGenerator = queryGenerator; QueryableXenoxContext = queryableXenoxContext; GridviewControl = gridView; DoNothing = i => { }; View = new VirtualQueryableCollectionView<T> { LoadSize = 30, VirtualItemCount = 100 }; View.ItemsLoading += (sender, args) => LoadInternal(args.StartIndex, args.ItemCount, DoNothing); View.FilterDescriptors.CollectionChanged += (sender, args) => LoadInternal(0, View.LoadSize, DoNothing); View.FilterDescriptors.ItemChanged += (sender, args) => LoadInternal(0, View.LoadSize, DoNothing); View.SortDescriptors.CollectionChanged += (sender, args) => LoadInternal(0, View.LoadSize, DoNothing); if (gridView == null) { ScrollIndexIntoView = DoNothing; } else { ScrollIndexIntoView = i => gridView.ScrollIndexIntoCenterOfView(i); } } public void Load(int currentIndex, int pageSize) { LoadInternal(currentIndex, pageSize, ScrollIndexIntoView); } public void Refresh(bool scrollToIndex = false, int currentIndex = 0) { var postLoadAction = scrollToIndex ? ScrollIndexIntoView : DoNothing; LoadInternal(currentIndex, View.LoadSize, postLoadAction); } public IEnumerable<T> GetAllCollectionItems() { return QueryableXenoxContext.Load(QueryGenerator(QueryableXenoxContext)).Entities; } private void LoadInternal(int currentIndex, int pageSize, Action<int> onLoaded) { if (currentIndex < 0) currentIndex = 0; //also load content above current item pageSize = pageSize*2; var loadStartIndex = currentIndex - pageSize / 2 < 0 ? 0 : currentIndex - pageSize / 2; var entityQuery = QueryGenerator(QueryableXenoxContext) .Sort(View.SortDescriptors) .Where(View.FilterDescriptors) .Skip(loadStartIndex) .Take(pageSize); entityQuery.IncludeTotalCount = true; try { QueryableXenoxContext.Load(entityQuery, LoadBehavior.RefreshCurrent, lo => { if (lo.TotalEntityCount != -1 && lo.TotalEntityCount != View.VirtualItemCount) { View.VirtualItemCount = lo.TotalEntityCount; } View.Load(loadStartIndex, lo.Entities); onLoaded(currentIndex); }, null); } catch (InvalidOperationException) { EventAggregator.Publish(new ErrorReportedEvent("Error loading items. Possible cause: too many items selected")); } }protected override void OnMouseDoubleClick(MouseButtonEventArgs e) { var element = InputHitTest(e.GetPosition(GetRowForItem(SelectedItem))); if (element != null) { if (DoubleClickCommand != null && DoubleClickCommand.CanExecute(DoubleClickCommandParameter)) DoubleClickCommand.Execute(DoubleClickCommandParameter); } base.OnMouseDoubleClick(e); }| <telerik:RadWindow x:Class="TestWpf.MainWindow" |
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" |
| Header="Test" Width="400" Height="200" |
| FocusManager.FocusedElement="{Binding ElementName=tbxUser}"> |
| <Grid> |
| <Label Content="User : " Height="28" Name="lblUser" /> |
| <TextBox Height="23" Name="tbxUser" Width="120"/> |
| </Grid> |
| </telerik:RadWindow> |
protected override void OnRotationAngleChanged(double newValue, double oldValue) { base.OnRotationAngleChanged(newValue, oldValue); List<RadDiagramShape> childrenList = Children.OfType<RadDiagramShape>().ToList(); // get rotation center double centerX = (ActualWidth / 2); double centerY = (ActualHeight / 2); foreach (RadDiagramShape item in childrenList) { RotateTransform transform = new RotateTransform(newValue, centerX, centerY); item.LayoutTransform = transform; } }