Telerik Forums
UI for WPF Forum
5 answers
917 views
I have a GridView that displays huge amounts of data. Moreover, columns are generated dynamically depending on the data and columns use custom DataTemplates. That said, GridView really takes some time to draw itself and virtualization feature is crucial for decent performace. However this feature is set to OFF once GridView height is not fixed. Obviously I want my GridView to occupy all available space and change its size when app window is resized. I.e. I want the effect equal to GridView.Height = Auto.

How can I achieve this - that GridView adjusts its size to available free space and still uses virtualization? 
Vlad
Telerik team
 answered on 30 Jul 2012
0 answers
71 views
Hi there

I want to arrange large number of some controls containing labels and buttons to be viewed on a window with the ability of resizing.

Is there any feature to implement what Google did in his image search?
In normal state, the control only shows some picture or labels,
but in mouse-over state it must be zoomed-up and all the contained controls like buttons, gauges, and more...

Thanks
پروژه
Top achievements
Rank 1
 asked on 30 Jul 2012
1 answer
518 views
Hi,

I'm trying to programmatically assign a header template for a column. The header template is similar to the GridViewSelectColumn as it just would have a checkbox in it, but I need the column to be able to bind to a property. I did look at the blog post from Vlad, but it will not work for this particular situation.

Below is the code I have to create a custom template (which works with for an ordinary ListView), but I don't know how to programmatically assign it to the column. I tried setting it to the column.Header property since it's of type object, but that did not work.

FrameworkElementFactory factory = new FrameworkElementFactory(typeof(CheckBox));
factory.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));
factory.AddHandler(CheckBox.UncheckedEvent, new RoutedEventHandler(GridViewAll_HeaderCheckBox_Checked));
factory.SetValue(CheckBox.ToolTipProperty, "(De)Select All");
 
DataTemplate template = new DataTemplate();
template.DataType = typeof(bool);
template.VisualTree = factory;

GridViewCheckBoxColumn column = new GridViewCheckBoxColumn();
column.DataMemberBinding = new Binding(prefix + property.Name);
column.Header = template // <-- this does not work

Thank you,
Tim

Dimitrina
Telerik team
 answered on 30 Jul 2012
2 answers
315 views
I have a GridView that is bound to a QueryableCollectionView. The QueryableCollectionView is constructed from an ObservableCollection, which is populated in code.  (So there's no messing about with LINQ to SQL ORMS, etc.)

I have a command implemented in the ViewModel (bound to a button and to a function key, but that's not important), that needs to check to see if any of the records contained in the grid have certain values in a certain field.

I'd thought I'd be able to do a simple LINQ query on the QueryableCollectionView, but it doesn't seem to work. Even the simplest won't compile.

This:

var customerids =
    from c in customersQueryView
    select c.customerid;

Results in: Instance argument: cannot convert from 'Telerik.Windows.Data.QueryableCollectionView' to 'System.Linq.IQueryable'

This:

var customerids =
    from c in customersQueryView.AsQueryable()
    select c.customerid;

Results in: Cannot convert lambda expression to type 'Telerik.Windows.Data.SelectDescriptorCollection' because it is not a delegate type.

The only workaround I've been able to find is to iterate through all the records with a foreach(), which results in considerably less clear code.
Jeff
Top achievements
Rank 1
 answered on 27 Jul 2012
3 answers
196 views
I've created a CustomGridViewToggleRowDetailsColumn class that descends from GridViewBoundColumnBase.  Its purpose is to display the row details toggle control only if the row in question contains data to be displayed in the row details.

In order to speed up the retrieval of data from my database, I have added a boolean flag to the view model object that is displayed in the RadGridView that indicates whether the object has data for the row details.  This flag is set when the row is retrieved from the database.  However, I do not want to retrieve the data for the row details at the same time.  Rather, I want to wait for the user to click on the button to expand the details and go get the data at that time.  The underlying View Model objects implement INotifyPropertyChanged, so the WPF controls get notification of changes.

The CustomGridViewToggleRowDetailsColumn class has a Click event that I want to program.  When the user clicks on the button, I want the code to check to see if the detail data has been retrieved from the database yet, and if not, to go and get it.

Here's the definition of the CustomGridViewToggleRowDetailsColumn class:

class CustomGridViewToggleRowDetailsColumn : GridViewBoundColumnBase {
  
    public static RoutedEvent ClickEvent =
        EventManager.RegisterRoutedEvent( "Click", RoutingStrategy.Bubble, typeof( ToggleRowDetailsColumnRoutedEventHandler ), typeof( CustomGridViewToggleRowDetailsColumn ) );
  
    public GridViewCell Cell { get; set; }
  
    public event RoutedEventHandler Click {
        add { AddHandler( ClickEvent, value ); }
        remove { RemoveHandler( ClickEvent, value ); }
    }
  
    public override object Header {
        get { return null; }
        set { base.Header = value; }
    }
  
    public GridViewToggleButton ToggleButton { get; set; }
  
    private Binding toggleButtonVisibility;
    public Binding ToggleButtonVisibility {
        get { return toggleButtonVisibility; }
        set { toggleButtonVisibility = value; }
    }
  
    public CustomGridViewToggleRowDetailsColumn() {
        this.EditTriggers = GridViewEditTriggers.None;
    }
  
    public override bool CanFilter() {
        return false;
    }
  
    public override bool CanGroup() {
        return false;
    }
  
    public override bool CanSort() {
        return false;
    }
  
    public override FrameworkElement CreateCellElement( GridViewCell cell, object dataItem ) {
        Cell = cell;
  
        ToggleButton = new GridViewToggleButton { 
            Margin = new System.Windows.Thickness( 3 )
        };
        ToggleButton.Click += new RoutedEventHandler( ToggleButton_Click );
  
        if ( this.DataMemberBinding != null ) {
            ToggleButton.SetBinding( GridViewToggleButton.IsCheckedProperty, this.DataMemberBinding );
        }
  
        if ( ToggleButtonVisibility != null ) {
            ToggleButton.SetBinding( GridViewToggleButton.VisibilityProperty, ToggleButtonVisibility );
        }
  
        GridViewRow row = cell.ParentRow as GridViewRow;
  
        row.SetBinding( GridViewRow.DetailsVisibilityProperty, new Binding( "IsChecked" ) { 
            Source = ToggleButton, 
            Converter = new BooleanToVisibilityConverter(), 
            Mode = BindingMode.TwoWay 
        } );
  
        return ToggleButton;
    }
  
    void ToggleButton_Click( object sender, RoutedEventArgs e ) {
        // Raise our Click event
        RoutedEventArgs newEventArgs = new ToggleRowDetailsColumnRoutedEventArgs( ClickEvent, Cell );
        RaiseEvent( newEventArgs );
    }
}
  
public class ToggleRowDetailsColumnRoutedEventArgs : RoutedEventArgs {
  
    public GridViewCell Cell { get; set; }
  
    public GridViewRow Row {
        get { return Cell.ParentRow as GridViewRow; }
    }
  
    public ToggleRowDetailsColumnRoutedEventArgs( RoutedEvent routedEvent, GridViewCell cell )
        : base( routedEvent ) {
        Cell = cell;
    }
}
  
public delegate void ToggleRowDetailsColumnRoutedEventHandler( object sender, ToggleRowDetailsColumnRoutedEventArgs e );

Here is the Click event handler that I wrote that is called when the user clicks on the toggle button for a row that has details to be displayed:

private void ExpandAlarms_Click( object sender, ToggleRowDetailsColumnRoutedEventArgs e ) {
    ReadViewModel read = e.Row.Item as ReadViewModel;
  
    if ( read.Alarms == null ) {
        read.Alarms = DataInterface.GetAlarmsForRead( read.ID );
    }
  
    e.Handled = true;
}

The problem is that the parameters to the ExpandAlarms_Click method always refer to the same row, no matter which row I click on.  I think there is something wrong, either in the ToggleButton_Click method or in the CreateCellElement method.  But I don't know what the issue could be.  I think I need to save the Cell passed to the CreateCellElement somewhere other than were I'm saving it now, but I'm not sure where that would be.

Please help

Tony
Tony
Top achievements
Rank 1
 answered on 27 Jul 2012
1 answer
153 views
Hello,

I have the following column defined in my xaml code

<
telerik:GridViewMaskedTextBoxColumn Mask="P1" MaskType="Numeric" 
DataMemberBinding="{Binding CurrentAllocationWeight}" 
DisplayIndex="1" IsReadOnly="True" DataFormatString="{}{0:P1}"  
Header="% Of Total" ColumnGroupName="CurrentAllocation"/> 

The bound property is a null-able decimal value. I have no other validation in the code-behind. When I try to enter a value in the cell, I get a validation error: "DecimalConverter cannot convert from System.Double".

How should I fix this, so that the user can enter say, 5.5, and it would display that value as "5.5%" in the cell?

Hasanain
Dimitrina
Telerik team
 answered on 27 Jul 2012
13 answers
570 views
Hi all,

I have two grids. Grid A has data where some of the columns have drop downs. Grid B is used to administrate the lists in the those drop downs.

When a change occurs in Grid B then the values in Grid A are updated using INotifyPropertyChanged. However, I also want validation to kick in (Its possible to delete values from Grid B but Grid A needs to have appropriate values)

For basic cell level validation I have used the cell validating event and that works pretty well. If possible, when Grid B has been updated I would want cell validation to start.

Thanks in advance

Arthur
Arthur
Top achievements
Rank 1
 answered on 27 Jul 2012
5 answers
263 views
Hi.

I'd like to be able to add more manipulation points to a RadDiagramConnection programmatically. Is this possible and how would I go about doing it?

Regards.
Alex Fidanov
Telerik team
 answered on 27 Jul 2012
1 answer
187 views
Let me edit this to be more clear.  I am trying to dynamically change the values of the needle, thus making it Animated and have it move according to the live data being stored.  I have live data that is being thrown in a Records (ObservableCollection<QRecords<double>>) which (QRecords) has the properties "Value" and "TimeStamp" in it.  In the ChartView control, I use:

var lineSeries = new LineSeries();
lineSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "TimeStamp" };
lineSeries.ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Value" };
lineSeries.ItemsSource = (chart.Chart as GuiAnalogQueue).Records;

to add a new LineSeries accompanied with addition VerticalAxes.  This is the binding that takes care of all my data changing dynamically. 

Now, I'm trying to apply this data to allow the user to user a Gauge to display the same data, just in a different fashion (Gauge vs. ChartView).  However, when I do something like
<telerik:Needle x:Name="needle" IsAnimated="True" Value="{Binding Value}"/>
or
<telerik:Needle x:Name="needle" IsAnimated="True" Value="{Binding chart.Chart.Value}"/>

My needle doesn't move at all, whatsoever.  What steps should I take to achieve changing the value of the Gauge's needle?

Kevin
Andrey
Telerik team
 answered on 27 Jul 2012
1 answer
96 views
I am currently working on a project which uses the RadGridView, part of the required functionality is to hide and show records based on various user interaction with the grid, it would appear the best way to get this to work is using a CompositeFilterDescriptor and add and remove the filters as required.

My issue is as follows, the project has been written using MVVM and from all the reading i have done it doesn't seem possible to use binding for the indvidual FilterDescriptor lines, the RadGridView in question is contained with in a datatemplate (and there maybe more than one on the screen at one time) so it's can't be accessed directly from the code behind.

So my question is, is there anyway of changing the FilterDescriptor lines with out directly accessing the grid from the code behind.

 

Dimitrina
Telerik team
 answered on 27 Jul 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?