Telerik Forums
UI for WPF Forum
2 answers
368 views

Hello,

I am using this example to get a row number in my gridview:
http://www.telerik.com/forums/how-to-display-the-row-number

I altered the code from the example and added a dependency property to it, which I am binding to a property of an item from the itemssource collection of the gridview.

public class RowNumberPresenter : TextBlock
{
    private GridViewDataControl _parentControl;
    public GridViewDataControl ParentControl
    {
        get { return this._parentControl; }
        private set
        {
            if (this._parentControl != null)
                this._parentControl.Items.CollectionChanged -= new NotifyCollectionChangedEventHandler(Items_CollectionChanged);
            this._parentControl = value;
            if (this._parentControl != null)
                this._parentControl.Items.CollectionChanged += new NotifyCollectionChangedEventHandler(Items_CollectionChanged);
        }
    }
  
    public RowNumberPresenter(GridViewDataControl parentControl, object dataItem)
        : base()
    {
        ParentControl = parentControl;
        SetText(dataItem);
    }
  
    private void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        SetText(this.DataContext);
    }
  
    private void SetText(object dataItem)
    {
        if (this.ParentControl.IsGrouping)
        {
            var group = this.ParentControl.FindGroupByItem(dataItem);
            if (group != null)
            {
                var items = group.Items as ReadOnlyObservableCollection<object>;
                if (items != null)
                    this.Text = (items.IndexOf(dataItem) + 1).ToString();
            }
        }
        if (string.IsNullOrWhiteSpace(this.Text))
            this.Text = (this.ParentControl.Items.IndexOf(dataItem) + 1).ToString();
    }
}

 

public class RowNumberGridViewColum : GridViewColumn
{       
    private RowNumberPresenter _rowNumberPresenter;
 
 
    public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
    {
        _rowNumberPresenter = cell.Content as RowNumberPresenter;
        if (_rowNumberPresenter == null)
            _rowNumberPresenter = new RowNumberPresenter(this.DataControl, dataItem);
             
        CurrentIndex = Int32.Parse(_rowNumberPresenter.Text);
        return _rowNumberPresenter;
    }
 
    public int CurrentIndex
    {
        get { return (int)GetValue(CurrentIndexProperty); }
        set { SetValue(CurrentIndexProperty, value); }
    }
 
    public static readonly DependencyProperty CurrentIndexProperty =
        DependencyProperty.Register("CurrentIndex", typeof(int), typeof(RowNumberGridViewColum));
}

 

<cControlsTelerik:RowNumberGridViewColum 
                IsReadOnly="True"
                TabStopMode="Skip"
                TextAlignment="Center"
                CurrentIndex="{Binding Path=OrderRowData.SequenceNumber}">
    <cControlsTelerik:RowNumberGridViewColum.Header>
        <TextBlock Text="No.:"/>
    </cControlsTelerik:RowNumberGridViewColum.Header>
</cControlsTelerik:RowNumberGridViewColum>


The binding is not working and I am I am a little stuck how to bind the rownumber of the row to my dataobject (a OrderRow object).
I receive the error that OrderRowData is not a property of OrderViewModel, OrderViewModel is my VM for the whole view?

The Itemssource of the gridview is set to a Rows property on my OrderViewModel, this Rows collection contains all the OrderRowData instances visible in the grid.

Any help would be appreciated.

Regards,

Marcel

 

Marcel
Top achievements
Rank 1
 answered on 06 Dec 2016
5 answers
324 views
 Lets say, i have 70 records, and currently in view is 18 records. Now, I am pressing tab for 19th time then scroll down to display 19th record. Scroll according to tab key navigation.
Please see attachment
Yoan
Telerik team
 answered on 06 Dec 2016
2 answers
260 views
Hello folks!


How can I add DockingPanesFactory to the RadDocking dynamically?

 <telerik:RadDocking 
                            x:Name="Docking"
                            >
            <telerik:RadDocking.DockingPanesFactory>
                <local:CustomDockingPanesFactory />
            </telerik:RadDocking.DockingPanesFactory>
   </telerik:RadDocking>

 var Dock = new Telerik.Windows.Controls.RadDocking();
.....
Any advise or suggestion will be greatly appreciated.

hokushin
Top achievements
Rank 1
 answered on 06 Dec 2016
1 answer
294 views
Hi, I try use RadChartView to display finance data with Candle-style series. After setup data, I set horizontal zoom, but vertical zoom remains unchanged (see screenshot). How to make radchartview auto-Y-scale  for visible part of chart?
Martin Ivanov
Telerik team
 answered on 06 Dec 2016
1 answer
665 views

Hello,

I am looking a generic solution to import excel to radgridview.

I want to do this at my control(not viewmodel or codebehind,I custimized radgridview)

Is there a way to do that

Lance | Senior Manager Technical Support
Telerik team
 answered on 05 Dec 2016
1 answer
195 views

Hello!

      I'm using the "RadRichTextBox" in my project. I'm facing a problem when the control is disabled (i.e. IsEnabled = False). In disabled state the controls turns Grey and the text visibility is very low. I cannot use read-only or any other property as they are being used for other purpose. I need to change the template for Disabled control, so as to not make it Grey but make the Disable mask transparent instead. Need help for the same.

Thanks

Tushar

     

Lance | Senior Manager Technical Support
Telerik team
 answered on 05 Dec 2016
3 answers
702 views

I am replacing a TreeView control with a RadTreeView control however I have run in to a issue. I want the user to be able to click on the body of the TreeView (instead of a node) and have it deselect the item in the tree view.

 

With the original TreeView I would do

<TreeView Grid.Row="0" MouseDown="TreeView_OnMouseDown">
    <TreeViewItem Header="Item 1"/>
    <TreeViewItem Header="Item 2"/>
</TreeView>

Then in the code behind I would have

private void TreeView_OnMouseDown(object sender, MouseButtonEventArgs e)
{
    var treeView = (TreeView)sender;
    var items = treeView.Items.Cast<TreeViewItem>();
    foreach (var treeViewItem in items)
    {
        treeViewItem.IsSelected = false;
    }
     
}

 

And this would work correctly. However if I do

<telerik:RadTreeView Grid.Row="1" MouseDown="RadTreeView_OnMouseDown">
    <telerik:RadTreeViewItem Header="Item 3"/>
    <telerik:RadTreeViewItem Header="Item 4"/>
</telerik:RadTreeView>

and

private void RadTreeView_OnMouseDown(object sender, MouseButtonEventArgs e)
{
    var treeView = (RadTreeView)sender;
    treeView.SelectedItem = null;
    MessageBox.Show("RadTreeView_OnMouseDown fired!");
}

the OnMouseDown event never fires.

Looking at the OnMouseDown event with Snoop it appears to be getting marked as handled by the ScrollViewer inside the RadListView.

What is the correct way to deselect the node when clicking on the body of the tree view? Attached is a simple example program that shows the two controls side by side with their different behaviors.

Scott
Top achievements
Rank 1
 answered on 05 Dec 2016
3 answers
283 views

Hi,

At the moment I'm facing an issue, I have a RadGridView which can show different tables with different definitions(not at the same time)
So AutoGenerateColumns is set to True.

now it can happen that some columns have an FK to another table.
Before I replaced those columns in the DataLoaded event but because of performance reasons I would like to do those replaces in the CurrentCellChanged event.

The problem when I do this is that the new GridViewComboBoxColumn misses the link to the actual datasource, and while reading the value for saving in the database, the value is DBNULL.

the gridview in de Xaml looks like this

<DataTemplate x:Key="AdminViewMainSectorTemplate">
        <Grid Margin="10">
            <Grid>
                <telerik:RadBusyIndicator x:Name="BusyIndicator" Grid.Row="2" >
                    <telerik:RadGridView x:Name="gridViewAdminData"
                                                     ItemsSource="{Binding DataRecords, Mode=TwoWay}"
                                         RowEditEnded="EditRecord"
                                         Deleted="deleteRecord"
                                         AddingNewDataItem="AddingNewDataItem"
                                         MinColumnWidth="100"
                                         ColumnWidth="*"
                                         NewRowPosition="Top"                                         
                                         AutoGeneratingColumn="AutoGeneratingColumn"
                                         DataLoading="LoadData"
                                         DataLoaded="DataLoaded"
                                         CurrentCellChanged="CurrentCellChanged"
                                         SelectionUnit="Cell"
                                         >
                        <!--DataLoading="LoadData"
                                         DataLoaded="DataLoaded"-->
                        <telerik:EventToCommandBehavior.EventBindings>
                            <telerik:EventBinding
                            Command="{Binding HandleAddingNewRecordToDevicesGridCommand}"
                            EventName="AddingNewDataItem"
                            PassEventArgsToCommand="True"/>
                        </telerik:EventToCommandBehavior.EventBindings>
                    </telerik:RadGridView>
                </telerik:RadBusyIndicator>
            </Grid>
        </Grid>
    </DataTemplate>

and my code behind looks like this:

private void CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e)
       {
           RadGridView rgv = (RadGridView)sender;
           GridViewCell cell = rgv.CurrentCell;
           if (cell != null && typeof(GridViewDataColumn) == cell.Column.GetType())
           {
               Models.MyEntities db = new Models.MyEntities();
               string tableName = Helpers.GlobalParameters.currenTableName;
               if (tableName =="batches")
               {
                   string fieldname = cell.Column.UniqueName;
                   if (fieldname == "ProductieOrderId")
                   {
                       int index = cell.Column.DisplayIndex;
                       GridViewComboBoxColumn cbb = new GridViewComboBoxColumn();
                       cbb.DataMemberBinding = new System.Windows.Data.Binding(fieldname);
                       //cbb.DataMemberBinding = cell.DataColumn.DataMemberBinding;
                       cbb.ItemsSource = db.productieorder.ToList();
                       cbb.SelectedValueMemberPath = fieldname;
                       cbb.DisplayMemberPath = "Id";
                       //cbb.Name = fieldname;
                       cbb.UniqueName = fieldname;
                       cbb.DisplayIndex = index;
                       rgv.Columns.Remove(cell.Column);
                       //rgv.Columns.Remove(cell.DataColumn);
                       rgv.Columns.Add(cbb);
 
                   }
               } else if (tableName =="artikel")

where the Field "Id" is the related field on the related table
If I do this
cbb.SelectedValueMemberPath = "Id";

what I would say is logical, the shown value in the combobox stays empty.

does anyone know where to look to fix this issue?

Martin
Telerik team
 answered on 05 Dec 2016
1 answer
249 views

Hi,

I am using a DataTemplateSelector and DataTemplates to show and interact with Custom Appointments in the schedule.

The Custom Appointment has a field called BindingItem added which holds a reference to my data.I then have checkboxes and drop down boxes that bind to fields within the BindingItem.

Everything works great until I refresh the entire appointments collection.

It seems like DataTemplates are being reused (by the container?) and any interaction seems to be with the old BindingItem not the new one, even though the appointment collection is brand new and each appointment has a new BindingItem set.

I can get this resolved in 2 ways, the first is to scroll the offending appointments off the screen and back again which must be forcing some kind of container refresh. Not very useful for end users.

The second is to use the following code to force a container refresh, note that AddIdleAction adds the code onto the dispatcher at application idle priority:

        private void RefreshAppointmentBindingItem(CustomAppointment appt)
        {
            if (appt != null)
            {
                object item = appt.BindingItem;

                AddIdleAction(() =>
                {
                    appt.BindingItem = null;
                });

                AddIdleAction(() =>
                {
                    appt.BindingItem = item;
                });
            }
        }

Both ways are messy, do you have any better suggestions?

Thanks

Anthony

Stefan
Telerik team
 answered on 05 Dec 2016
6 answers
190 views
I have an RTF document that is made up of many smaller RTF documents merged together.  The document that I am using for testing contains over 1100 pages. Printing this document setting the Document property of a RadRichTextBox and calling the print method is very slow.  I can open the same document in Word and it prints about 10 times faster.  Are there any recommendations for improving printing performance?  Thanks.
tushar
Top achievements
Rank 1
 answered on 05 Dec 2016
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?