Telerik Forums
UI for WPF Forum
1 answer
337 views
We are using WPF with the MVVM pattern. When a button on the View is clicked on by the user, the command is bound to an item in the ViewModel for handling it. This successfully adds a new line to the bottom of the master grid (if the currently selected line is the last), then adds a child line to the selected row. Finally it calls a Mediator.Instance.NotifyColleagues (Cinch) in order to basically signal an event that is picked up in the View's code behind. I have tried several variations but am unable to get the second column of the first child row to go into edit mode. I did try IsInEditMode = true and BeginEdit().

Of great concern is the following lines where I expect to get all of the RadGridViews contained within the master, as well as all of the rows.
var grids = grid1.ChildrenOfType<RadGridView>();
var rows = grid1.ChildrenOfType<GridViewRow>();

Instead, I get null for grids and only 1 for rows??? I was expecting something like 8 for grids count and 26 for rows count. I am aware that the children have a completely separate RadGridView than the master, however, I am explicitly indicating grid1 (the master RadGridView) in this case.

The code behind message sink is as follows (and using a breakpoint - it clearly gets hit at the expected time too).
[MediatorMessageSink(MediatorConstants.Cashbook_ChildStatementLineFocus)]
        private void Cashbook_ChildStatementLineFocusMessageSink(int currentRowIndex)
        {
 
            if (grid1.ItemsSource != null)
            {
 
                grid1.ExpandHierarchyItem(this.grid1.Items[currentRowIndex]);
 
                Dispatcher.BeginInvoke((Action)delegate
                {
                    var grids = grid1.ChildrenOfType<RadGridView>();
                    var rows = grid1.ChildrenOfType<GridViewRow>();
 
                    foreach (var row in rows)
                    {
                        if (grid1.SelectedItem == this.grid1.Items[currentRowIndex])
                        {
                            var child = row.ChildrenOfType<RadGridView>().FirstOrDefault();
                            child.SelectedItem = child.Items[0];
 
                            var column = child.Columns[1];
                            var cellToEdit = new GridViewCellInfo(child.SelectedItem, column, child);
                            child.CurrentCellInfo = cellToEdit;
                            child.BeginEdit();
 
                        }
 
 
                    }
 
 
 
                });
 
                //RadGridView childGrid = this.grid1.ChildrenOfType<RadGridView>().FirstOrDefault(x => ((DOFinBankStatementTran)x.ParentRow.DataContext).BankStatementTranID == ((DOFinBankStatementTran)this.grid1.CurrentItem).BankStatementTranID);
                //if (childGrid != null)
                //{
                //    var item = childGrid.Items[0];
                //    var column = this.grid1.Columns[1];
                //    var cellToEdit = new GridViewCellInfo(item, column, childGrid);
 
                //    childGrid.CurrentCellInfo = cellToEdit;
                //    childGrid.BeginEdit();
                //}
            }
 
        }


If it helps, the method in the ViewModel looks as follows:
private void ExecuteDissectionCommand()
        {
            try
            {
                DOFinBankStatementTran currentLine = SelectedStatementLine;
 
                if (currentLine == StatementLinesSource.Last())
                {
                    AddNewLineCommand.Execute(true);
                }
 
                if (currentLine.Children == null)
                {
                    currentLine.Children = new List<DOFinBankStatementTran>();
                    DOFinBankStatementTran line = CurrentClientHelper.ClientFinancial.CreateBankStatementTran(currentLine.GLBankAccount);
                    line.ParentStatementTranID = currentLine.BankStatementTranID;
                    line.GLBankAccountID = currentLine.GLBankAccountID;
                    line.GLBankAccount = currentLine.GLBankAccount;
                    line.HasChildren = false;
                    line.ImageForIsEditable = currentLine.ImageForIsEditable;
                    line.IsActive = true;
                    line.IsDeleted = false;
                    line.IsPosted = false;
                    line.IsReconciled = false;
                    currentLine.Children.Add(line);
                    currentLine.HasChildren = true;
                }
                 
 
                int i = StatementLinesSource.IndexOf(currentLine);
                StatementLinesSource.RemoveAt(i);
                StatementLinesSource.Insert(i, currentLine);
 
 
                Mediator.Instance.NotifyColleagues<int>(MediatorConstants.Cashbook_ChildStatementLineFocus, i);
            }
            catch (Exception ex)
            {               
                //check if exception type is global exception and throw
                ExceptionHelper.CheckExceptionType(ex, typeof(GlobalException));
                 
                _messageBoxService.ShowError("DissectionCommand Error:"+ex.Message);
                CurrentClientHelper.ClientAudit.LogException(ex, EventCategory.Client);
            }
        }


And without boring everyone to tears the two RadGridViews in the XAML (one master and one child template for hierarchy) are as follows:

grid1 - the master RadGridView
<telerik:RadGridView x:Name="grid1"  Grid.Row="1" Grid.Column="0" ShowGroupPanel="False" AutoGenerateColumns="False"
                                     RowIndicatorVisibility="Collapsed" IsReadOnly="False"
                                     CanUserInsertRows="False" EditTriggers="CellClick"
                                     RowLoaded="grid1_RowLoaded"
                                     ItemsSource="{Binding StatementLinesSource,Mode=TwoWay}"
                                     SelectedItem="{Binding SelectedStatementLine, Mode=TwoWay}"
                                     BeginningEdit="grid1_BeginningEdit"
                                     IsSynchronizedWithCurrentItem="False"
                                     aps:SingleEventCommand.RoutedEventName="CellEditEnded"
                                     aps:SingleEventCommand.CommandParameter="{Binding ElementName=grid1, Path=CurrentCell.Column.UniqueName}"
                                     aps:SingleEventCommand.TheCommandToRun="{Binding CellEditEndedCommand}"
                                     abs:RadGridViewKeyboardBehaviour.IsEnabled="True"
                                     abs:RadGridViewKeyboardBehaviour.EnterDirection="MoveNext"
                                     ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                     EnableColumnVirtualization="True"
                                     EnableRowVirtualization="True"  
                                     UseLayoutRounding="False"
                                     >

gridChildren - the HierarchyChildTemplate RadGridView
<telerik:RadGridView x:Name="gridChildren" CanUserFreezeColumns="False"
                                                 AutoGenerateColumns="False" ItemsSource="{Binding Children}" 
                                                 ShowGroupPanel="False"
                                                 CanUserInsertRows="True"
                                                 SelectionChanged="gridChildren_SelectionChanged"
                                                 RowEditEnded="gridChildren_RowEditEnded"
                                                 RowValidating="gridChildren_RowValidating"
                                                 RowLoaded="gridChildren_RowLoaded"
                                                 abs:RadGridViewKeyboardBehaviour.IsEnabled="True"
                                                 abs:RadGridViewKeyboardBehaviour.EnterDirection="MoveNext"
                                                 EditTriggers="CellClick" IsTabStop="True"
                                                 DataLoaded="gridChildren_DataLoaded"
                                                 >


Of course, there are lots of event handlers declared in the Constructor and so on but I am not including the entire solution just enough to try and assist anyone with helping to solve this problem. We were trying to keep our code behind to a minimum but I fail to see how I can do things like set the focus of a row in a RadGridView and set a particular cell to be in edit mode from the ViewModel without the ViewModel having some sort of awareness of the View (presentation layer) which it should not. If I have missed something here and am heading down the wrong path then kindly enlighten me. :)

Thanks,
Rob

Nedyalko Nikolov
Telerik team
 answered on 28 May 2011
1 answer
105 views
Hi,

I had to re-template the RadSplitButton to change the colour of the text on the button. I should be able to do that just by changing the Foreground property but it is ignored at the moment. Not a big one but it can be a problem for WPF newbies.

Re-templating in Blend and adding Foreground="{TemplateBinding Foreground}" to the RadButton declaration does the trick. I would also add other ones for the Font related formats (Bold, etc)

Jose
Dimitrina
Telerik team
 answered on 28 May 2011
4 answers
209 views
Hi all

I need to display an inage on column header of a data grid along with the sort arrow.
How can i acieve this in WPF
swati
Top achievements
Rank 1
 answered on 28 May 2011
2 answers
636 views


I am using tab control in main window to dynamically load content in tab items. I am doing this by binding collection of my page view models to the items source of the tab control. Everything works fine except it seams like view of my page models is reloading each time I select another tab and then return to one I just left. I suppose this is related to virtualization.

Problem with this is that switching tabs can be slow or unresponsive and also all property changes on the view not bind to view model are lost when you switch tab.

Is it possible to change this behavior and make tab content static? 

Igor Stefanovic
Top achievements
Rank 1
 answered on 28 May 2011
1 answer
113 views
Hi all,

I have a requirement to show an image on column along with the sort arrow. So that user willl came to know about the columns on the basis of which data is being sorted.
 help me out....
Vanya Pavlova
Telerik team
 answered on 28 May 2011
3 answers
639 views
Hi,

I would like to know if it's possible to "Copy" cells content of a RadGridView using Windows "Copy/Paste" standard function?

Thank's
Dimitrina
Telerik team
 answered on 28 May 2011
14 answers
507 views
Hello,

is it possible to create the following with the Telerik-GridView:

I'have got some columns which should have two rows of columnheaders. The first line of the columnheader contains a summary (rubric) and should be centered. The captions of the columns should follow in the next line.

Is there a type of cell-span in the GridView?

Please have a look to the screenshot for better unterstanding (first two rows are essential).


Greetings from Germany

Markus
Mike Bennett
Top achievements
Rank 1
 answered on 27 May 2011
0 answers
101 views
Hi, 
I'm doing a student portal project. I'm using asp.net 3.5, and vb.net for codebehind.
I have a problem in the registration section.
See I have 3 gridviews, the first girdview lists all available courses for the current semester, it has a selection option.
when the user clicks on select, the second gridview appears showing availabe sections for a specific course, this gridview has a checkbox controler, when the user check it, the third gridview appears.
this third gridview is for the user to view all the possible going to register sections with a confirm button
once the confirm button is clicked, all needed data is saved in the database.
the thing is, I want the system to check if a specific student had registered for this course before, if he did he can't register to any sections of this course again. i'm having problem in doing that.
involved tables in database are : student, course,  section and student2section
one course has many sections.
many student can register to many sections so we have an intermediary table called student2setcion
can anyone help please??
AA
Top achievements
Rank 1
 asked on 27 May 2011
2 answers
287 views
I have a VB Class Library that has a WPF Window in it with a RadGridView on the window.  My class library has references to Telerik.Windows.Controls, Telerik.Windows.Controls.Data, Telerik.Windows.Controls.GridView, Telerik.Windows.Controls.Input and Telerik.Windows.Data.  When I compile the class library I get the following error in the vb.g file of the WPF Window:
Error 1 Type 'Telerik.Windows.Controls.RadGridView' is not defined. C:\Development\BestpassEM\WPFInfrastructure\obj\Debug\Infrastructure\ResultsWindow.g.vb 58 35 Bestpass.UI.Infrastructure

What could be causing this?  The line it is occuring on is below.
#ExternalSource("..\..\..\Infrastructure\ResultsWindow.xaml",18)
<System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")>  _
Friend WithEvents datagrid As Telerik.Windows.Controls.RadGridView
  
#End ExternalSource

Betsy
Top achievements
Rank 1
 answered on 27 May 2011
3 answers
433 views
Hi Telerik,

I'm having trouble triggering the ContextMenuOpening event in order to handle the event and not show the context menu.

With standard WPF context menu I would handle the event on the control owning the context menu, but I can't seem to get this right with RadContextMenu control. Hope you can guide me on how to achieve this. I have a code block as below:

<telerik:RadCalendar Grid.Row="1" Margin="6,6,6,6" x:Name="calendar" IsTodayHighlighted="False" telerikControls:StyleManager.Theme="Vista"
            DayTemplateSelector="{StaticResource templateSelector}" Columns="4" Rows="3" ViewsHeaderVisibility="Visible" FirstDayOfWeek="Monday"
            HeaderVisibility="Visible" ContextMenuOpening="calendar_ContextMenuOpening">
    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu x:Name="cmCalendar" Opened="ContextMenuCalendar_Opened" telerikControls:StyleManager.Theme="Vista">
            <telerik:RadMenuItem x:Name="miHoliday" Header="{x:Static local:CentralCalendarWindowGlossary.miHoliday_Header}" Click="MenuItemHoliday_Click" IsCheckable="True" ToolTipService.ShowOnDisabled="True" ToolTipService.IsEnabled="{Binding Path=IsEnabled}" ToolTip="{DynamicResource toolTipDefault}" />
            <telerik:RadMenuItem x:Name="miNoDistribution" Header="{x:Static local:CentralCalendarWindowGlossary.miNoDistribution_Header}" IsCheckable="True" Click="MenuItemNoDistribution_Click" ToolTipService.ShowOnDisabled="True" ToolTipService.IsEnabled="{Binding Path=IsEnabled}" ToolTip="{DynamicResource toolTipDefault}" />
            <telerik:RadMenuItem IsSeparator="True" />
            <telerik:RadMenuItem x:Name="miSiteDistribution" Header="{x:Static local:CentralCalendarWindowGlossary.miSiteDistribution_Header}" Click="MenuItemSiteDistribution_Click" ToolTipService.ShowOnDisabled="True" ToolTipService.IsEnabled="{Binding Path=IsEnabled}" ToolTip="{DynamicResource toolTipDefault}">
                <telerik:RadMenuItem.Icon>
                    <Image Source="/AN.Planner.Administrator;component/Images/SiteDetailsViewSmall.ico" />
                </telerik:RadMenuItem.Icon>
            </telerik:RadMenuItem>
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
</telerik:RadCalendar>

The event never invokes "calendar_ContextMenuOpening"

Thanks in advance,
Best regards
Kasper Schou
Kasper Schou
Top achievements
Rank 1
 answered on 27 May 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?