Telerik Forums
UI for WPF Forum
2 answers
531 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
148 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
139 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
69 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
121 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
1 answer
261 views
I need to build a chrome less window that has metro-styled controls to close, maximize, the window. I see DevComponents supports this but I'd prefer to use your tools. Do you support this? If so, how? I didn't see it in your demos/samples.
Vanya Pavlova
Telerik team
 answered on 08 Sep 2011
25 answers
347 views
Hello,

We have come across an error when trying to use a date picker in a grid (v2009.1.413.35).  When you try to open a date picker that is being used in a grid an 'Object reference not set to an instance of an object' exception is thrown.  This problem seems to only occur on machines running Vista 64. 

Steps to reproduce:
1. Install the Telerik controls on a machine running Vista 64
2. Launch the Example app
3. Go to the GridView Editors example
4. Try to edit a date column

Here's the stack trace:
2009-03-25 14:22:40,609 [1] ERROR IRC.Gear.WorkItemManager.Wpf.App - Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren() at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren() at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree() at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

Please let me know when there is a fix available.

Thanks,

Joel



Rossen Hristov
Telerik team
 answered on 07 Sep 2011
3 answers
71 views
Hello,

I have a panelbar inside of a Radpane. When I have my items (menu) on the PanelBar "expanded" and I pin or unpin the RadPane, I lost all my expanded items, and shows it all closed.

Any solution?

Thanks.
Regards.
Konstantina
Telerik team
 answered on 07 Sep 2011
3 answers
131 views
I have a GridView with a column having two buttons: Edit and Delete. The GridView current item is the row that is highlighted that in some cases happens to be different from the row where the Edit/Delete button was clicked, therefore returning the wrong current item

Example: Grid has 4 rows. Row 1 happens to be highlighted. If the user clicks on either one of the Edit/Delete buttons in Row 2, we get Row 1 current item, instead of Row 2

Below is the XAML declaration for the Grid View

<telerik:RadGridView Grid.Column="0" Grid.Row="0" Width="1324" HorizontalAlignment="Left" Name="grvRetScheduleTerms" VerticalAlignment="Top" AutoGenerateColumns="False"
                     ActionOnLostFocus="None" CanUserFreezeColumns="False" SelectionUnit="FullRow" SelectionMode="Single" IsSynchronizedWithCurrentItem="True"                                      
                     CanUserDeleteRows="True" IsReadOnly="False" CanUserSelect="True" CanUserInsertRows="False" FontSize="16"
                     AddingNewDataItem="grvRetScheduleTypes_AddingNewDataItem" RowEditEnded="grvRetScheduleTypes_RowEditEnded">
Marcelo
Top achievements
Rank 1
 answered on 07 Sep 2011
1 answer
154 views
Hi Telerik Team,

I'm trying to create footer which will display elements count on predefined group .Net 4 with latest release of WPF controls (2011.2.712)

I'm using code below to create predefined group descriptor and later add aggregate funtion on column to show it in footer unfortunetly this is not working.

<telerik:RadGridView x:Name="RadGridView1" ShowGroupFooters="True" AutoGenerateColumns="False" >
            <telerik:RadGridView.GroupDescriptors>
                <telerik:GroupDescriptor Member="Name">
                    <telerik:GroupDescriptor.AggregateFunctions>
                        <telerik:CountFunction />
                    </telerik:GroupDescriptor.AggregateFunctions>
                </telerik:GroupDescriptor>
            </telerik:RadGridView.GroupDescriptors>
             
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Age}" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" >
                    <telerik:GridViewDataColumn.AggregateFunctions>
                        <telerik:CountFunction Caption="count:" />
                    </telerik:GridViewDataColumn.AggregateFunctions>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
Vanya Pavlova
Telerik team
 answered on 07 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
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
VirtualKeyboard
HighlightTextBlock
Security
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?