Hello,
Here is my situation:
1. I have got client app in WPF ( Cant create here any db context etc )
2. I have got Rest Api where is DbContext (EntityFramework)
3. I have got RadGrid and RadPager
I want to pass QueryableCollectionView or QueryableEntityCollectionView or something else? to this rest api, processing data, use filters, pagination and sorters from radgrid. Then in returns i want to receive collection of Products, Employees or something
Is any body do something like this? I know that in Blazor UI there is DataSourceRequest etc and it works fine, but i did not find alternative in WPF
Hello,
I use RadPdfViewer to view a PDF file in my WPF application, the PDF file has only one page and the contents are in the middle of the page, so I'm trying to zoom and focus on the middle of the page, I use the following code:
private void DocumentChanged(object sender, DocumentChangedEventArgs e)
{
pdfViewer.ScaleFactor = 1.3;
var size = pdfViewer.Document.Pages[0].Size;
pdfViewer.ScrollToVerticalOffset(size.Height * 0.3);
pdfViewer.ScrollToHorizontalOffset(size.Width * 0.20);
}
however, I only see the horizontal scroll working.
How can I zoom then scroll to vertical and horizontal offset?
Hello,
I have a strange behavior during grouping.
When I drag a column to the header and the grouping is performed then you redraw the RadGridView layout.
Sometimes I see the first group at the middle of the grid instead of the top (there is an empty space in half of the grid). If I scroll a little bit then the layout is fixed and the grid looks as expected.
I tried to InvalidateVisual on the Grouped event but it looks the same. How do I solve it ?
Hello,
I am working with a RadGridView and developed two features:
1. A ListBox that displays the RadGridView's columns where the user can check/uncheck some columns or all of them. The purpose of the control is to show or hide the columns according to the CheckBox state.
2. User Settings mechanism that saves the columns visibility status to a file. After the application starts, I load the IsVisible status to the columns and override the configured value in the xaml.
I noticed that the default behavior in RadGridView is to show the rows even when there are 0 visible columns and the SelectedItem remains.
I would like to hide the rows and unselect the items.
I tried to use a data trigger to do this funcionality.
It works with a DataTrigger when the value Columns.Count = 0.
To finish this functionality I would like to update the data trigger to the Visible Columns count, which is not provided by Telerik.
How can I do that?
I tried to create an attached property that maintains a counter when the user change the state of the columns visibility from the ListBox, but it does not work when the state is changed from the xaml or the user settings.
I don't want to bind to Columns Collection Changed and Visibility Changed because I think it is an overhead for this functionality.
Can you expose this property or help me with a better solution?
Hi Telerik Community,
How can I get programmaticaly the result of a column aggregate ? I tried something like "Column.Footer" but my footer is <null>...
I have thought of something like "Column.Footer.Cell.Value" or maybe "Column.AggregateResult"...
Regards,
Matthieu M
A list is to be displayed using the RadTreeListView. It should be possible to add a single element or to delete several selected elements. As soon as a new element is added, all other elements should be deselected and the new element should be selected.
The problem is that if a certain number of elements is deleted, afterwards just as many newly added elements are automatically deselected, although they were previously explicitly selected programmatically.
Example with test application
Initial state:
→ Click "Add" to add a new element:
→ Click "Delete" to delete selected element (for simplicity the automatically selected element just added is used):
→ Click "Add" to add a new element:
Element 4 should now be selected.
→ Click "Add" to add a new element:
Now it works again as expected.
The same behavior can be replicated with deleting multiple elements. Afterwards, exactly this number of then newly added elements are deselected, although they should be selected. After that the behavior is as expected again.
View
<StackPanel>
<Button Click="Add_Button_Click">Add</Button>
<Button Click="Delete_Button_Click">Delete</Button>
<telerik:RadTreeListView ItemsSource="{Binding VM.Elements}"
SelectionMode="Multiple"
IsSynchronizedWithCurrentItem="False"
RowIndicatorVisibility="Collapsed"
>
<telerik:RadTreeListView.RowStyle>
<Style TargetType="{x:Type telerik:TreeListViewRow}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
</Style>
</telerik:RadTreeListView.RowStyle>
</telerik:RadTreeListView>
</StackPanel>
CodeBehind
public partial class MainWindow : Window
{
public ViewModel VM { get; set; }
public MainWindow()
{
InitializeComponent();
VM = new ViewModel();
DataContext = this;
}
private void Add_Button_Click(object sender, RoutedEventArgs e)
{
VM.AddNewData();
}
private void Delete_Button_Click(object sender, RoutedEventArgs e)
{
VM.Elements.RemoveAll(x => x.IsSelected);
}
}
ViewModel
public class ViewModel
{
public ObservableCollection<Data> Elements { get; set; } = new ObservableCollection<Data>();
public ViewModel()
{
Enumerable.Range(0, 3).ForEach(_ => AddNewData());
Elements.CollectionChanged += Data_CollectionChanged;
}
public void AddNewData()
{
Elements.Add(new Data());
}
private void Data_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
Elements.ForEach(x => x.IsSelected = false);
e.NewItems?.OfType<Data>().ForEach(x => x.IsSelected = true);
}
}
public class Data : INotifyPropertyChanged
{
static private int counter = 0;
public event PropertyChangedEventHandler? PropertyChanged;
private bool isSelected = false;
public bool IsSelected
{
get
{
return isSelected;
}
set
{
isSelected = value;
OnPropertyChanged(nameof(IsSelected));
}
}
public int Id { get; set; } = counter++;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Hi,
Im using conversationalUI in a WPF app and would like to update the message in realtime as my openAI response is streaming in to make the UX a better experience on long responses. This should update the message being displayed in realtime as the service is streaming in text.
I only see the ability to do a message.Add() option, I feel like there should also be a AddAsync() method. Is this even possible in this control?
Thanks in advance!
If I have subscribed to the RadCarouselPanel.SelectedIsTopItem event, should I not get notifications when that property changes to false?
In my case, when the user scrolls the mouse wheel over the control or hits the little left/right buttons at the bottom of the carousel, the selected item certainly moves off of the top. But the event is never fired. It is only fired when I left click on the item to make the control force it to the top.
To illustrate, here is how I find the panel and subscribe to the events
var panel = this.Carousel.FindChildByType<RadCarouselPanel>();
panel.IsAnimatingChanged += Panel_IsAnimatingChanged;
panel.SelectedIsTopItem += Panel_SelectedIsTopItem;
I then have debug log lines in the two handler functions to let me know when the events fire.
private void Panel_SelectedIsTopItem(object sender, RoutedEventArgs e)
{
var panel = (RadCarouselPanel)sender;
Log.Debug($"Panel SelectedIsTopItem changed to {panel.IsSelectedTopItem}");
}
private void Panel_IsAnimatingChanged(object sender, RoutedEventArgs e)
{
var panel = (RadCarouselPanel)sender;
Log.Debug($"Panel is animating changed to {panel.IsAnimating}");
}
When I bring up my display the selected item is at the top by default
Then I use the mouse wheel or the scroll buttons to move the panel items without changing the selected item. Note that the blue "selected" rectangle still appears around #002 to the left even though it is not #003 that is topmost
But all I get in my log is IsAnimatingChanged events
15:31:50.690 [ 1] DEBUG - Panel_IsAnimatingChanged: Panel is animating changed to True
15:31:50.977 [ 1] DEBUG - Panel_IsAnimatingChanged: Panel is animating changed to False
But now if I left-click the new topmost item (#003), then it becomes selected
and I am notified that SelectedIsTopMost has changed, along with an event about IsAnimating changed even though no animation occurs in this instance
15:36:16.447 [ 1] DEBUG - Panel_IsAnimatingChanged: Panel is animating changed to True
15:36:16.725 [ 1] DEBUG - Panel_SelectedIsTopItem: Panel SelectedIsTopItem changed to True
15:36:16.730 [ 1] DEBUG - Panel_IsAnimatingChanged: Panel is animating changed to False
In order for the event SelectedIsTopMost to be useful to me, I have to be notified about it when it becomes false. Why am I not being told this?
For sake of completeness, here is my XAML
<tk:RadCarousel x:Name="Carousel"
Padding="0" Margin="0"
Grid.Row="1"
ItemsSource="{Binding ScansView}"
VerticalContentAlignment="Top"
IsVisibleChanged="Carousel_OnIsVisibleChanged"
HorizontalAlignment="{Binding HorizontalAlignment}" VerticalAlignment="{Binding VerticalAlignment}"
>
I have the following XAML
<Window x:Class="WpfApp46.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp46"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="1200"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<telerik:RadGridView ItemsSource="{Binding Foos}" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Foo1}" MinWidth="100" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Foo2}" MinWidth="100" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Foo3}" Width="*" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Foo4}" MinWidth="100" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Foo5}" MinWidth="100" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Foo6}" MinWidth="100" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</Window>
and the following code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp46
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public List<Foo> Foos { get; set; }
public MainWindow()
{
Foos = new List<Foo>()
{
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
new Foo() { Foo1 = "Foo 1", Foo2 = "Foo 2", Foo3 = "Foo 3", Foo4 = "Foo 4", Foo5 = "Foo 5", Foo6 = "Foo 6" },
};
InitializeComponent();
}
}
public class Foo
{
public string Foo1 { get; set; }
public string Foo2 { get; set; }
public string Foo3 { get; set; }
public string Foo4 { get; set; }
public string Foo5 { get; set; }
public string Foo6 { get; set; }
}
}
Hello.
I have the same situation as https://www.telerik.com/forums/virtual-page-count.
Since the database has over 100 million data, I don't want to bring all the data into memory.
When a user clicks on a specific page, I'm trying to get only the data in that range from the DBMS.
I also read about Unbound Mode (https://docs.telerik.com/devtools/wpf/controls/raddatapager/features/unbound-mode)
But this seems to use code-behind.
I don't want to write a code-behind because I use the MVVM pattern.
How can I do it?
The code below has been simplified.
1. DataView.xaml
<UserControl x:Class="MyProject.Views.MyDataView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MyProject.Views"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
d:DesignHeight="550" d:DesignWidth="1920">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="26" />
<RowDefinition Height="400"/>
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Page Size" Margin="2 8 12 2" FontWeight="SemiBold"/>
<telerik:RadComboBox
Height="22"
Margin="0 0 10 0"
FontFamily="Segoe UI"
ClearSelectionButtonVisibility="Visible"
ClearSelectionButtonContent="Show all"
DisplayMemberPath="DisplaySize"
ItemsSource="{Binding MyDataPageSize}"
SelectedItem="{Binding SelectedMyDataPageSize}"
AllowMultipleSelection="False"
Command="{Binding RefreshMyDataCommand}"/>
</StackPanel>
</Grid>
<telerik:RadGridView x:Name="MyDataGridView"
Grid.Row="1"
IsFilteringAllowed="False"
AutoGenerateColumns="False"
ShowGroupPanel="False"
CanUserFreezeColumns="False"
RowIndicatorVisibility="Collapsed"
SelectionMode="Extended"
TextBlock.TextAlignment="Center"
CanUserSortColumns="False"
IsReadOnly="True"
Margin="10 5 10 0"
ScrollMode="RealTime"
ItemsSource="{Binding DynamicGridViewItemSource}"
</telerik:RadGridView>
<telerik:RadDataPager Grid.Row="2"
x:Name="MyDataPager"
Width="{Binding ElementName=MyDataGridView, Path=ActualWidth}"
PageSize="{Binding SelectedMyDataPageSize.Size}"
Source="{Binding Items, ElementName=MyDataGridView}"
ItemCount="{Binding TotalItemCount}"
BorderThickness="1,0,1,1"
DisplayMode="All"
AutoEllipsisMode="Both"
NumericButtonCount="10"
IsTotalItemCountFixed="False" >
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="PageIndexChanged">
<behaviors:InvokeCommandAction Command="{Binding PageIndexChangedCommand}"
CommandParameter="{Binding ElementName=MyDataPager, Path=PageIndex}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</telerik:RadDataPager>
</Grid>
</UserControl>
2. DataViewModel.cs
namespace MyProject.ViewModels
{
public class StageDTO
{
public string StartNumber { get; set; }
public string EndNumber { get; set; }
}
public class MyDataViewModel : ViewModelBase
{
// some code
private int _totalItemCount;
public int TotalItemCount
{
get
{
return _totalItemCount;
}
set
{
_totalItemCount = value;
OnPropertyChanged(nameof(TotalItemCount));
}
}
public MyDataViewModel(CyclerMode mode)
{
// do something
}
public void ShowMyDataOfSelectedStage(object parameter)
{
StageDTO dto = parameter as StageDTO;
// do something
// and i calculate TotalItemCount here
TotalItemCount = Convert.ToInt32(dto.EndNumber) - Convert.ToInt32(dto.StartNumber);
}
}
}
There may have been a typo in the process of simplifying, but there is no problem when i actually run the program.
TotalItemCount = Convert.ToInt32(dto.EndNumber) - Convert.ToInt32(dto.StartNumber);
The data goes in correctly in the code above, but nothing changes.
I made the changes below, but it still doesn't work.
ItemCount="{Binding TotalItemCount, UpdateSourceTrigger=PropertyChanged}"
If I change it like below
ItemCount="{Binding TotalItemCount, Mode=TwoWay}"
I am getting an exception like below.
System.InvalidOperationException: 'Setting RadDataPager.ItemCount is allowed in Unbound Mode only.'
How do I get it to work like I want?