Telerik Forums
UI for WPF Forum
3 answers
85 views
Here is the class that populates each row:

 

    public class TableData  
    {  
        private string name;  
        private Image image = new Image();  
 
        public string Name  
        {  
            get { return name; }  
            set { name = value; }  
        }  
        public Image Picture  
        {  
            get { return image; }  
            set { image = value; }  
        }  
        public TableData(string s)  
        {  
            Name = s;  
            image.Source = new BitmapImage(new Uri("captain-scarlet.jpg", UriKind.RelativeOrAbsolute));  
        }  
    }  
 

Here is how I set up the grid:

 

            ObservableCollection<TableData> theData = new ObservableCollection<TableData>();  
            theData.Add(new TableData("1a"));  
            theData.Add(new TableData("2a"));  
            radGridView1.ItemsSource = theData;  
 

 


The grid view appears and the name column shows data ok, but the image column is blank.
I see in the debugger that both columns in the grid are of type GridViewDataColumn. Should the image one be a GridViewImageColumn? If so, how do I set it up?

Any help appreciated - I'm trying to evaluate it for a potentially big project!
Thanks
Bruce


 

Vlad
Telerik team
 answered on 12 Jan 2010
1 answer
625 views
I need to have a context menu on a grid whereby I can determine which column the user right-clicked on. I create the columns dynamically with the following code:

        private void CreateNewColumn(FieldDescriptor fd, uint fieldno) { 
            fieldGrid.Columns.Add(new GridViewDataColumn() { 
                UniqueName = fd.fieldName, 
                Header = fd.displayName, 
                DataMemberBinding = new Binding("Fields[" + fieldno + "]"), 
                ContextMenu = new ContextMenu() { 
                    Items = { 
                        new MenuItem() { 
                            Header = "Field Properties"
                            Command = Commands.FieldProperties, 
                            CommandBindings = { new CommandBinding(Commands.FieldProperties, FieldProperties_Execute) }  
                        }, 
                        new MenuItem() { 
                            Header = "Delete Field"
                            Command = Commands.DeleteField, 
                            CommandBindings = { new CommandBinding(Commands.DeleteField, DeleteField_Execute) } 
                        } 
                    } 
                } 
            }); 
        } 

Unfortunately the popup menu never appears when I right click anywhere on the grid. If I bind the context menu to the grid (i.e. fieldGrid.ContextMenu = new ContextMenu() {...) then the menu pops up, but I have no way to tell what column was clicked. Is there a way to make this work?

Thanks,
Ferruccio


Vlad
Telerik team
 answered on 12 Jan 2010
4 answers
338 views
Hi Team,

I have a Parent Grid In my page,
Its having hierarchical (projects >> tasks >> comments) data.
My Task grid contains 3 Tab items

I can able to load Tasks  GridView (first tab grid).
But second and third tab grid data are not loaded
Always shows empty GridView

cs page

ProjTasks = GetData(); 
if (outlookProjTasks != null) 
            { 
                GridViewTableDefinition detail1 = new GridViewTableDefinition(); 
                detail1.Relation = new PropertyRelation("Tasks"); 
                detail1.Relation.Name = "Tasks"
 
                GridViewTableDefinition detail2 = new GridViewTableDefinition(); 
                detail2.Relation = new PropertyRelation("ActiveTasks"); 
                detail2.Relation.Name = "ActiveTasks"
 
                GridViewTableDefinition detail3 = new GridViewTableDefinition(); 
                detail3.Relation = new PropertyRelation("CompletedTasks"); 
                detail3.Relation.Name = "CompletedTasks"
 
                this.GrdProjectTasks.TableDefinition.ChildTableDefinitions.Add(detail1); 
                this.GrdProjectTasks.TableDefinition.ChildTableDefinitions.Add(detail2); 
                this.GrdProjectTasks.TableDefinition.ChildTableDefinitions.Add(detail3); 
 
                this.GrdProjectTasks.RowDetailsVisibilityMode = Telerik.Windows.Controls.GridView.GridViewRowDetailsVisibilityMode.VisibleWhenSelected; 
                this.GrdProjectTasks.ItemsSource = ProjTasks
            } 

XAML File

<Grid.Resources> 
            <my:FormattingConverter x:Key="formatter" /> 
            <!--<telerik:RadGridView x:Key="DataSource"/>--> 
            <Style TargetType="telerik:ChildDataControlsPresenter"
                <Setter Property="Template"
                    <Setter.Value> 
                        <ControlTemplate TargetType="telerik:ChildDataControlsPresenter"
                            <TabControl> 
                                <TabItem  Header="All Tasks"
                                    <telerik:RadGridView x:Name="radGridView1" RowLoaded="radGridView1_RowLoaded" LoadingRowDetails="radGridView1_LoadingRowDetails" Height="Auto"  
                                    ShowGroupPanel="True" Margin="0,0,0,0" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" AutoGenerateColumns="True" FontFamily="Segoe UI" FontSize="11" FontStretch="5"
                                        <telerik:RadGridView.Columns> 
                                            <telerik:GridViewToggleRowDetailsColumn /> 
                                        </telerik:RadGridView.Columns> 
                                    </telerik:RadGridView> 
                                </TabItem> 
                                <TabItem Header="Active Tasks"
                                    <telerik:RadGridView x:Name="grdActiveTasks" Height="200" ShowGroupPanel="True" Margin="0,0,0,0" RowIndicatorVisibility="Collapsed"  
                                            CanUserFreezeColumns="False" AutoGenerateColumns="True" FontFamily="Segoe UI" FontSize="11" FontStretch="5" ItemsSource="{Binding ActiveTasks}"
                                    </telerik:RadGridView> 
                                    <!--ItemsSource="{Binding MasterRecord.Data.ActiveTasks}"--> 
                                </TabItem> 
                                <TabItem Header="Completed Tasks"
                                    <telerik:RadGridView x:Name="grdCompletedTasks" Height="200" ShowGroupPanel="True" Margin="0,0,0,0" RowIndicatorVisibility="Collapsed" 
                                            CanUserFreezeColumns="False" AutoGenerateColumns="True" FontFamily="Segoe UI" FontSize="11" FontStretch="5" ItemsSource="{Binding Tasks}"
                                        <telerik:RadGridView.Columns> 
                                            <telerik:GridViewDataColumn DataMemberBinding="{Binding Subject}" Header="Subject"/> 
                                        </telerik:RadGridView.Columns> 
                                    </telerik:RadGridView> 
                                    <!--ItemsSource="{Binding MasterRecord.Data.CompletedTasks}"--> 
                                </TabItem> 
                            </TabControl> 
 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
            <Style x:Key="GridViewAlternateRowStyle" TargetType="telerik:GridViewRow"
                <Setter Property="Background" Value="#303030" /> 
                <Setter Property="Foreground" Value="White" /> 
                <Setter Property="BorderThickness" Value="1" /> 
                <Setter Property="BorderBrush" Value="Black" /> 
            </Style> 
 
            <Style x:Key="GridViewRowStyle" TargetType="telerik:GridViewRow"
                <Setter Property="Background" Value="#606060" /> 
                <Setter Property="Foreground" Value="White" /> 
                <Setter Property="BorderThickness" Value="1" /> 
                <Setter Property="BorderBrush" Value="Black" /> 
            </Style> 
        </Grid.Resources> 
 
 <telerik:RadGridView Margin="1,60,0,0" RowIndicatorVisibility="Collapsed" IsFilteringAllowed="True"  Name="GrdProjectTasks" FontFamily="Segoe UI" FontSize="11" FontStretch="5" 
            UseAlternateRowStyle="True" ShowGroupPanel="True" CanUserFreezeColumns="False" IsReadOnly="True" RowLoaded="GrdProjectTasks_RowLoaded" 
            DataLoadMode="Asynchronous" RowStyle="{StaticResource GridViewRowStyle}" AlternateRowStyle="{StaticResource GridViewAlternateRowStyle}" GroupPanelBackground="#FF202020"  
            CanUserSortColumns="False" BorderThickness="0" Grid.Column="1" Height="740" Width="1024" Grid.ColumnSpan="2"
            <!--my:GridViewFilterRow.IsEnabled="True"--> 
        </telerik:RadGridView> 


Can you please help on this issue

Regards
Shanthi

shadhan
Top achievements
Rank 1
 answered on 12 Jan 2010
0 answers
126 views
Hello,
     When a column on the grid is re-ordered there appears to be only the DisplayIndexMap object in the grid to keep track of the new order. This object is protected so I cannot get at it directly. Since I could not figure out how to determine the new order on the grid side I changed the column order of the datatable to match the grid's.

In the ColumnDisplayIndexChanged event of the grid I added this line of code, which takes care of the re-ordering:

<datatable name>.Columns[e.Column.Header.ToString()].SetOrdinal(e.Column.DisplayIndex);

This event will be triggered twice. Once for the column that was moved and again for the column that was shifted over for the moved column.

When I print the contents of the grid I use the datatable as the data source.


Jorge Gonzalez
Top achievements
Rank 1
 asked on 11 Jan 2010
0 answers
128 views
Hello,
    I finally figured out how to filter a grid associated with a datatable. Instead of filtering the grid, which was a traumatic experience, I filtered the datatable associated with the grid instead. It took less than 7 lines of code and most of those lines of code were for creating the filter expression:

I am collecting a bunch of values in another window so I can filter the varnames column in my grid so:

string filterexpression = "varnames in (" + < bunch of values> + ")"
gridname.ItemsSource = <datatable name>.Select(filterexpression, <supply sort expression>, DataViewRowState.CurrentRows);

Jorge Gonzalez
Top achievements
Rank 1
 asked on 11 Jan 2010
3 answers
136 views
Hello,

I would like to evaluate wether a Drop Operation on a specfic RadtreeViewItem is allowed.
I got a WPF Radtreeview with hierachical Data Binding, Multiselection and Drag&Drop occurs only within the Treeview.
Therefore I added a Event Handler to the DropQuery Event of the RadTreeview.

RadTreeView1.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler&lt;DragDropQueryEventArgs&gt;(RadTreeView_DropQuery), true); 


For my Decision it is necessary to know which RadtreeviewItems are dragged. I don´t need the dragged data objects, because my decision is based on parent of each dragged RadtreeviewItem.

 
private void RadTreeView_DropQuery(object sender, DragDropQueryEventArgs e) 
        { 
 
            bool dropPossible = checkIfDropPossible(draggedRadTreeViewItems); 
            
            if (dropPossible) 
            { 
                e.QueryResult = true
            } 
            else 
            { 
                e.QueryResult = false
            } 
}                     


Therefore I need a way to get the dragged RadtreeviewItems in the DropQueryEvent. I searched all e.Options members but I get the responding data objects (e.Options.Payload) only.

How can I get corresponding dragged RadTreeViewItems to the DataObjects in the DropQueryEvent? Any help is welcome.

Best Regards
Akiono Wan
Valentin.Stoychev
Telerik team
 answered on 11 Jan 2010
4 answers
111 views
Hi,

I'm using RadTreeView control for WPF Q2 2009, with values

IsOptionElementsEnabled

 

="True"  

 

ItemsOptionListType="CheckList"  

 

IsTriStateMode="True"

the treeview is collapsed. If i check first root item but not expand the node, CheckedItems only return one item. Otherwise if I expand the node, CheckedItems returns the root item node and subitems.

Is there any option to avoid that?

This is the example:

 

<telerik:RadTreeView   
            IsLineEnabled="True"   
            IsOptionElementsEnabled="True" 
            ItemsOptionListType="CheckList"    
            IsTriStateMode="True" 
            IsRootLinesEnabled="True"    
 
            controls:StyleManager.Theme="Vista" 
        > 
            <telerik:RadTreeViewItem Header="Item0">  
                <telerik:RadTreeViewItem Header="Item1.1"/>  
                <telerik:RadTreeViewItem Header="Item1.2"/>  
            </telerik:RadTreeViewItem> 
            <telerik:RadTreeViewItem Header="Item1">  
                <telerik:RadTreeViewItem Header="Item1.1"/>  
                <telerik:RadTreeViewItem Header="Item1.2"/>  
            </telerik:RadTreeViewItem> 
            <telerik:RadTreeViewItem Header="Item2">  
                <telerik:RadTreeViewItem Header="Item1.1"/>  
                <telerik:RadTreeViewItem Header="Item1.2"/>  
            </telerik:RadTreeViewItem> 
 
        </telerik:RadTreeView> 

When I check node Item0 but not expand it, CheckedItems returns Item 0 only (this happens only the first time node is collapsed)
But expanding it, CheckedItems returns Item 0, Item1.1, Item1.2. (if i collapsed the node again, CheckedItems returns Item 0, Item1.1, Item1.2)

 

Also I set theme to Vista (controls:

StyleManager.Theme="Vista" ) but I get an orange backgound when mouse is over the nodes. Is this ok?

Thanks and best regards,
Alberto

 

 

question_forum
Top achievements
Rank 1
 answered on 11 Jan 2010
2 answers
172 views
In the method signature for the event handler for the event 'Edited' there are the following parameters: ( object sender, RadTreeViewItemEditedEventArgs e ).

How can I get the RadTreeViewItem that is being edited? e.OriginalSource returns an 'EditableHeaderedItemsControl' and sender returns the RadTreeView. Is there something I am missing?

Thank you.

EDIT:

OK, I was able to cast e.OriginalSource to RadTreeViewItem. The problem that I am encountering is that I want to delete the node if its header is empty. So inside the Edited event handler I have the following code:

item.ParentItem.Items.Remove(item); 

I get the following null exception:

   at Telerik.Windows.Controls.RadTreeViewItem.CommitEdit() in c:\Builds\WPF_Scrum\Navigation_WPF\Sources\Development\Controls\Navigation\TreeView\RadTreeViewItem.cs:line 718
   at Telerik.Windows.Controls.RadTreeView.HandleItemSelectionFromUI(RadTreeViewItem treeViewItemToSelect) in c:\Builds\WPF_Scrum\Navigation_WPF\Sources\Development\Controls\Navigation\TreeView\RadTreeView.cs:line 2196
   at Telerik.Windows.Controls.RadTreeViewItem.OnHeaderMouseLeftButtonDown(Object sender, MouseButtonEventArgs e) in c:\Builds\WPF_Scrum\Navigation_WPF\Sources\Development\Controls\Navigation\TreeView\RadTreeViewItem.Events.cs:line 790
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   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)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()


Ziad
Top achievements
Rank 1
 answered on 11 Jan 2010
7 answers
132 views
I have a project that I'm deving from scratch.

SQL database
wpf and web
stock/inventory  - ordering, tracking

anybody interested in helping me out..  
Vlad
Telerik team
 answered on 11 Jan 2010
1 answer
105 views
I want to initiate sort on the grid from code.  I am not having success.

This is what I've tried:

gvDocumentListing.Columns[4].SortingState = Telerik.Windows.Controls.SortingState.Descending;

 

gvDocumentListing.Rebind();



This does not work.  I saw in an earlier post that some one called Columns.Reset().    This method appears to have been removed.
Vlad
Telerik team
 answered on 11 Jan 2010
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
DataPager
PersistenceFramework
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
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?