Telerik Forums
UI for WPF Forum
5 answers
126 views
RadGridView gets empty when I use CollectionViesSource with different inherited classes. Here is the example:

I created following window:
<Window x:Class="WpfApplication6.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <CollectionViewSource Source="{Binding Source={x:Static Application.Current}, Path=Employees}" x:Key="employees"/>
    </Window.Resources>
    <Grid>
        <telerik:RadGridView ItemsSource="{Binding Source={StaticResource employees}}" Margin="12,12,0,120" />
        <ListBox ItemsSource="{Binding Source={StaticResource employees}}" Margin="12" Height="102" VerticalAlignment="Bottom" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Name}" Margin="8" />
                        <TextBlock Text="{Binding Id}" Margin="8"  />
                        <TextBlock Text="{Binding Class}" Margin="8"  />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Window>


And codebehind:
namespace WpfApplication6
{
    public partial class App : Application
    {
        public ObservableCollection<Employee> Employees { get; set; }
 
        private void Application_Startup(object sender, StartupEventArgs e)
        {          
            Employees = new ObservableCollection<Employee>();
            Employees.Add(new Employee() { Name = "Alice", Id = 1 });
            Employees.Add(new Employee() { Name = "Bob", Id = 2 });
            Employees.Add(new Employee() { Name = "Charlie", Id = 3 });
            new MainWindow().Show();
        }      
    }
 
    public class Employee
    {
        public string Name { get; set; }
        public int Id { get; set; }
        public virtual string Class { get { return "Base"; } }
    }
 
    public class ExtendedEmployee : Employee
    {
        public override string Class { get { return "Extended"; } }
    }
}


In this example everything is ok, RadGridView and ListView displays same results. In following example everything is ok too:
Employees.Add(new ExtendedEmployee() { Name = "Alice", Id = 1 });
Employees.Add(new ExtendedEmployee() { Name = "Bob", Id = 2 });
Employees.Add(new ExtendedEmployee() { Name = "Charlie", Id = 3 });


But if I'll use mixed collection RadGridView become empty and ListBox will display correct results:
Employees.Add(new Employee() { Name = "Alice", Id = 1 });
Employees.Add(new Employee() { Name = "Bob", Id = 2 });
Employees.Add(new ExtendedEmployee() { Name = "Charlie", Id = 3 });

Screenshot is attached.
What's the problem here?
Dimitrina
Telerik team
 answered on 08 Sep 2011
1 answer
113 views
I am not sure if I missed it but I am unable to find any property or setting where I can keep the Transition Control pages from reloading. For example I have the control load with three web browsers. I do a Google search in one of them, switch to another one, come back to the Google page and my search results are gone as the control has reloaded. If this is by design I'll need to come up with another solution as I was wanting to use the Transition control for pages (and I could have anything on those pages from a win32 wrapped exe to web browser to pure wpf controls) that stay active until closed.

TIA
JB
Miroslav Nedyalkov
Telerik team
 answered on 08 Sep 2011
2 answers
135 views
Is there a way with the RadMAskedCurrencyInput to not have the long __,__,__ with it?


Thanks,

S
Alex Fidanov
Telerik team
 answered on 08 Sep 2011
1 answer
166 views
Hi ... we have found some strange behviour when hosting Windows Workflows inside the RadDocking component. I have attached an example solution which demonstrates the problem. Basically it seems that the Click is being captured somewhere and is not making it to the combo to open it. The Workflow designer in the soltuion is shown working outside the Docking component, and not working inside it. To test the problem, just run the solution and then try and click the 2 combos.

Demo Solution
Miroslav Nedyalkov
Telerik team
 answered on 08 Sep 2011
1 answer
95 views
I have created a application in which I added a Scroll Viewer and in it a canvas is applied. In canvas  a RadMenu is attached. In it a RadMenuItem is placed. And its sub child is created. When I move the scroll bar child moves along the scroll bar. So please tell me the solution of this problem.

Code is attached here..........
<Grid>
        <ScrollViewer>
            <Canvas Height="2000" Background="AliceBlue">
                <telerik:RadMenu >
                    <telerik:RadMenuItem Header="asd">
                        <telerik:RadMenuItem Header="child"></telerik:RadMenuItem>
                    </telerik:RadMenuItem>
                </telerik:RadMenu>
            </Canvas>
        </ScrollViewer>
   </Grid>
Ivo
Telerik team
 answered on 08 Sep 2011
2 answers
560 views
Hi,

I have a simple project with a RadTreeView and two button (add/delete) bind to ICommand from my model.
<Window.Resources>
    <Style x:Key="itemStyle"  TargetType="telerik:RadTreeViewItem">
        <Setter Property="IsSelected" Value="{Binding Path=Select, Mode=TwoWay}" />
        <Setter Property="IsExpanded" Value="{Binding Path=Expand, Mode=TwoWay}" />
        <Setter Property="IsInEditMode" Value="{Binding Path=EditMode, Mode=TwoWay}" />
    </Style>
</Window.Resources>
  
<DockPanel>
    <StackPanel Orientation="Vertical" DockPanel.Dock="Bottom">
        <Button Command="{Binding AddCommand}">Add Person</Button>
        <Button Command="{Binding DeleteCommand}">Delete current</Button>
    </StackPanel>
    <telerik:RadTreeView IsEditable="True" ItemsSource="{Binding Persons}" ItemContainerStyle="{StaticResource itemStyle}" SelectedItem="{Binding Path=Current, Mode=TwoWay}">
        <telerik:RadTreeView.ItemTemplate>
            <HierarchicalDataTemplate ItemsSource="{Binding Childs}">
                <TextBlock Text="{Binding Name}"/>
            </HierarchicalDataTemplate>
        </telerik:RadTreeView.ItemTemplate>
    </telerik:RadTreeView>
</DockPanel>

1 When I try to add an item my AddCommand add a item in my binding collection
Persons.Add(new PersonViewModel(new Model.Person("New person", new string[]{})) { Select=true, EditMode=true});
With this way the RadTreeViewItem is well editing but fill with text "RadTreeSample.ViewModel.PersonViewModel" and not "New Person". If i change EditMode=true to EditMode=false the item is well selected and well filled and i can edit correctly after. How to enable EditMode correctly ?

2 When i delete an item it will be fun if previous item become selected. First idea was to change the selected item in the DeleteCommand BUT i think that it's not the job of the ViewModel, it's typically a job for the View. How can i implement this ? The goal is that View and ViewModel have no reference between them.
if (Current != null)
{
    if (Current.Parent != null) Current.Parent.Childs.Remove(Current);
    else person.Remove(Current);
    // Not the role to viewmodel to select another element
}
luc
Top achievements
Rank 1
 answered on 08 Sep 2011
2 answers
166 views
Hi,

How can I recalculate AggregateResults for group footers?
I know it can be accomplished by calling rebind method on grid but I cannot use it as it is changing order of items. Is there any other why to do that?

Bartosz
Bartosz
Top achievements
Rank 1
 answered on 08 Sep 2011
1 answer
160 views
I have a list of zipcode objects that I bind to a datagridview based on a selection from a treeview, the treeview is unimportant other than only a subset of available zipcodes are bound to the grid at any one time.

GridSelectedZipCodes.ItemsSource = ZipGeoCodeService.GetForZipPart((string)item.Header, (float)_selectedDealer.Latitude, (float)_selectedDealer.Longitude, (float)_selectedDealer.MaxDistance);

where GetForZipPart has a function signature of:

static public List<ZipGeoCode> GetForZipPart(string zippart, float latitude, float longitude, float distance)

I want to select items in the gridview based upon another list of ZipGeoCode objects that correspond to a dealer.  The dealer list may contain zipcodes from other zipparts that are not bound to the grid.  I do the selection like so:

private void SelectZipCodes()
{
    IsLoading = true;
    foreach (ZipGeoCode _item in GridSelectedZipCodes.Items)
    {
        if (_dealerZipCodes.Find(delegate(ZipGeoCode zgc) {return zgc.ID == _item.ID; }) != null)
        {
            GridSelectedZipCodes.SelectedItems.Add(_item);
        }
    }
    IsLoading = false;
}


so far so good, however now when an item is selected or deselected in the radgridview I want to add or remove it from the _dealerZipCodes in the most efficient manner.  I suspect i shoudl use the radgrdiview_selectionchanged event.  I am wondering if ther is a way to do this with observable collections?.  Any suggestions greatly appreciated and info how I can act only on the item(s) that were selected/deselected by accessing the

SelectionChangeEventArgs

would be great.

I'm not using MVVM.

Currently my radgrdiview_selectionchanged looks like the following:

private void GridSelectedZipCodes_SelectionChanged(object sender, SelectionChangeEventArgs e)
       {
           if (!(IsLoading))
           {
               //remove all items
               foreach (ZipGeoCode _item in GridSelectedZipCodes.Items)
               {
                   if (_dealerZipCodes.Find(delegate(ZipGeoCode zgc) { return zgc.ID == _item.ID; }) != null)
                   {
                       _dealerZipCodes.Remove(_item);
                   }
               }
               foreach (ZipGeoCode _item in GridSelectedZipCodes.SelectedItems)
               {
                   _dealerZipCodes.Add(_item);
               }
           }
       }

Not very efficient.

Thanks for the help/direction.

For a visual of what I'm doing: http://www.metamorpho-sys.com/telerik/Capture.GIF

Jonathan


Maya
Telerik team
 answered on 08 Sep 2011
2 answers
77 views
As the title,I find little message support this question. I saw that datapager support any Collection implement IEnum...,but when I Use it on a ItemControl, it dosen't work,dose it only surpport Telerik or which Telerik Control does it Support?

Best wishes to TelerikTeam,Thanks! 
Yu
Top achievements
Rank 1
 answered on 08 Sep 2011
1 answer
136 views
Hey guys,

I'm trying to sync my selected gridview row with the ICollectionView. I have installed an older version (2010.2.924.35) and the new version 2011.2.712.35. The same implementation works with the older version and don't works with the new version.

So, let have a look at my code:

The code of the ViewModel:

#region Deklarationen
private ObservableCollection<RWF_GUI_TransferItems> _Items;
/// <summary>
/// Enthält alle Elemente die in dem GridView dargestellt werden.
/// </summary>
public ObservableCollection<RWF_GUI_TransferItems> Items
{
    get { return _Items; }
    set {
            _Items = value;
            this.ValueChanged("Items");
        }
}
 
 
private ICollectionView _ItemsView;
/// <summary>
/// View zur Überwachtung des aktuellen Grid-Items
/// </summary>
public ICollectionView ItemsView
{
    get { return _ItemsView; }
    set {
            _ItemsView = value;
            this.ValueChanged("ItemsView");
        }
}
 
 
private RWF_GUI_TransferItems _AktuelleGridAuswahl;
/// <summary>
/// Aktuelle Gridzeile
/// </summary>
public RWF_GUI_TransferItems AktuelleGridAuswahl
{
    get { return _AktuelleGridAuswahl; }
    set {
            _AktuelleGridAuswahl = value;
            this.ValueChanged("AktuelleGridAuswahl");
        }
}
 
public MainViewModel()
{
    this.Items = new ObservableCollection<RWF_GUI_TransferItems>();
 
    this.ItemsView = CollectionViewSource.GetDefaultView(this.Items);
    this.ItemsView.CurrentChanged += new EventHandler(OnCurrentItemChanged);
}
 
 
void OnCurrentItemChanged(object sender, EventArgs e)
{
    this.AktuelleGridAuswahl = (RWF_GUI_TransferItems)this.ItemsView.CurrentItem;
}

The XAML-Code:

<telerik:RadGridView ItemsSource="{Binding ItemsView}"
                     RowHeight="25"
                     CanUserFreezeColumns="False"
                     AutoGenerateColumns="False"
                     ShowColumnFooters="true"
                     x:Name="GridViewMain" IsSynchronizedWithCurrentItem="True"
                     IsEnabled="{Binding AtWork, Converter={StaticResource NegateBoolConverter}}">

The Items the ItemsView contains are correctly displayed in the GridView. But the OnCurrentItemChanged-Event is only being raised on startup (this.ItemsView.CurrentItem is null at this moment).

What can I do to get it work?

Thank you very much!
Best regards from Germany



Dimitrina
Telerik team
 answered on 08 Sep 2011
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
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
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
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?