Telerik Forums
UI for WPF Forum
1 answer
136 views
Hello,

I'm using two cascading ComboBoxColumns in my grid

<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding Assigns}" >
<telerik:RadGridView.Columns>
                    <telerik:GridViewComboBoxColumn Header="Client" ItemsSource="{Binding}"    
                        DataMemberBinding="{Binding ClientID}" DisplayMemberPath="Name" SelectedValueMemberPath="ID" />
                    <telerik:GridViewComboBoxColumn Header="Personalist" ItemsSourceBinding="{Binding AvailablePersons}"    
                        DataMemberBinding="{Binding PersonID}" DisplayMemberPath="Name" SelectedValueMemberPath="ID" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

I've followed this thread to achieve same cascading logic with comboboxes, but with LINQ to SQL Datasource  - no luck

DataClassesDataContext db = new DataClassesDataContext();
((GridViewComboBoxColumn)this.RadGridView1.Columns[0]).ItemsSource = db.Clients;
  
this.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(comboSelectionChanged));

private void comboSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RadComboBox comboBox = (RadComboBox)e.OriginalSource;
  
            if (comboBox.SelectedValue == null
                || comboBox.SelectedItem.GetType() != typeof(Client)) 
                return;
  
            Assign assign= comboBox.DataContext as Assign;
            assign.ClientID = (int)comboBox.SelectedValue;
}

This is the part where I got stuck, I've created an extra field AvailablePersons, but I can't get selected ID from first ComboBoxColumn:

public IEnumerable<Person> AvailablePersons
        {
            get
            {
                return from p in db.Persons
                       where p.ClientID == this.ClientID //???????????????????????????
                       select p;
            }
        }

Thank You for any help
Pavel Pavlov
Telerik team
 answered on 30 May 2011
2 answers
69 views
Something strange! When I try to dock a pane in another pane, the "diamond" shows outside the target-pane.
Even outside the window.
It worked great before. What's going on?
I tried to attach some pictures, but I don't know how...
Rieni De Rijke
Top achievements
Rank 1
 answered on 30 May 2011
2 answers
56 views
Hi,
How can we Incorporate the RadContextMenu for StackedBar Chart.
I tried to use the example given in the help for Bar Chart, but result in invisible Bars with context menu is opening on right click of it.

Please let me know what are changes I need to do on the Style, so that the bars get visible.
Here is the code for the Style:

<Style TargetType="telerik:StackedBar" x:Key="CommonContextMenu">
           <Setter Property="Template" >
               <Setter.Value>
                   <ControlTemplate TargetType="telerik:StackedBar">
                       <Canvas Opacity="0" x:Name="PART_CanvasContainer">
                           <telerik:RadContextMenu.ContextMenu>
                               <telerik:RadContextMenu ItemClick="RadContextMenu_ItemClick">
                                   <telerik:RadMenuItem Header="Go To Home Page" />
                                   <telerik:RadMenuItem Header="Go To Employee Page" />
                               </telerik:RadContextMenu>
                           </telerik:RadContextMenu.ContextMenu>
                           <Rectangle x:Name="PART_DefiningGeometry" 
                                  Height="{TemplateBinding ItemActualHeight}"
                                  Width="{TemplateBinding ItemActualWidth}"
                                  Style="{TemplateBinding ItemStyle}"
                                  RadiusX="{StaticResource BarRadiusX}"
                                  RadiusY="{StaticResource BarRadiusY}" />
                           <Rectangle Height="{TemplateBinding ItemActualHeight}"
                                  Width="{TemplateBinding ItemActualWidth}"
                                  RadiusX="{StaticResource BarRadiusX}"
                                  RadiusY="{StaticResource BarRadiusY}"
                                  OpacityMask="{StaticResource BarOpacityMaskBrush}"
                                  Fill="{StaticResource BarMaskBrush}" />
                           <Rectangle Height="{TemplateBinding ItemActualHeight}"
                                  Width="{TemplateBinding ItemActualWidth}"
                                  RadiusX="{StaticResource BarRadiusX}"
                                  RadiusY="{StaticResource BarRadiusY}"
                                  Fill="{StaticResource BarTopMaskBrush}" />
                           <Canvas.RenderTransform>
                               <ScaleTransform x:Name="PART_AnimationTransform" ScaleY="0" />
                           </Canvas.RenderTransform>
                       </Canvas>
                   </ControlTemplate>
               </Setter.Value>
           </Setter>
       </Style>

Please reply as soon as possible.
Thanks.
Manishkumar
Top achievements
Rank 1
 answered on 30 May 2011
1 answer
56 views
HI..
 Can you please help me in preventing radtileviewitem state Change under button click
Kiril Stanoev
Telerik team
 answered on 28 May 2011
1 answer
298 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
90 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
178 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
574 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
94 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
574 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?