Telerik Forums
UI for WPF Forum
4 answers
186 views
RadControls for WPF Q3 2009.

I have an ObservableCollection<T> with a class that implements INotifyPropertyChanged, bound to a RadGridView.

A column on the RadGridView implements a GridViewDataColumn for summing and displaying in a footer.

The Sum, shows up correctly upon running the application, however whenever a cell is edited, the sum does not update to reflect the new figure.
Am I supposed to invoke something to update the column sum?

Additionally, Columns are right aligned.  Upon entering a leaving the cell, the data is left aligned.  Is this a bug?

using System;  
using System.ComponentModel;  
 
public class Product : INotifyPropertyChanged  
{
    #region fields  
    private string _id;  
    private string _name;  
    private double _unitPrice;  
    private DateTime _date;
    #endregion  
 
    #region ctor  
    public Product()  
    {  
 
    }  
 
    public Product(string id, string name, double unitPrice, DateTime date)  
    {  
        _id = id;  
        _name = name;  
        _unitPrice = unitPrice;  
        _date = date;  
    }
    #endregion  
 
    #region properties  
    public string ID  
    {  
        get { return _id; }  
        set 
        {  
            _id = value;  
            NotifyPropertyChanged("ID");  
        }  
    }  
 
    public string Name  
    {  
        get { return _name; }  
        set 
        {  
            _name = value;  
            NotifyPropertyChanged("Name");  
        }  
    }  
 
    public double UnitPrice  
    {  
        get { return _unitPrice; }  
        set 
        {  
            _unitPrice = value;  
            NotifyPropertyChanged("UnitPrice");  
        }  
    }  
 
    public DateTime Date  
    {  
        get { return _date; }  
        set 
        {  
            _date = value;  
            NotifyPropertyChanged("Date");  
        }  
    }
    #endregion  
 
    #region Interface INotifyPropertyChanged  
    public event PropertyChangedEventHandler PropertyChanged;  
 
    private void NotifyPropertyChanged(string propertyName)  
    {  
        if (PropertyChanged != null)  
            PropertyChanged(thisnew PropertyChangedEventArgs(propertyName));  
    }
    #endregion  
}  
 

public Window6()  
{  
    InitializeComponent();  
 
 
    ObservableCollection<Product> list2 = new ObservableCollection<Product>();  
    list2.Add(new Product("A""Apple", 11.23, DateTime.Now));  
    list2.Add(new Product("B""Banana", 1.123, DateTime.Now));  
    list2.Add(new Product("C""Cherry", 112.3, DateTime.Now));  
    list2.Add(new Product("D""Durian", 12.3, DateTime.Now));  
    list2.Add(new Product("E""Eggplant", 1.23, DateTime.Now));  
    list2.Add(new Product("F""Fireberry", .123, DateTime.Now));  
    list2.Add(new Product("G""Golfball", 1.12, DateTime.Now));  
    list2.Add(new Product("H""Help", 1.13, DateTime.Now));  
 
    Binding binding = new Binding();  
    binding.Source = list2;  
    RadGridView1.SetBinding(RadGridView.ItemsSourceProperty, binding);  

<grid:RadGridView Grid.Row="1" Margin="0,0,0,1" x:Name="RadGridView1" ItemsSource="{Binding RandomProducts}" ShowColumnFooters="True" ShowGroupFooters="True" Width="900" 
             AutoGenerateColumns="False" IsReadOnly="False" CanUserFreezeColumns="False">  
    <grid:RadGridView.Columns> 
        <grid:GridViewDataColumn Header="ID" DataMemberBinding="{Binding ID}">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:CountFunction Caption="Count: " /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
        </grid:GridViewDataColumn> 
        <grid:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:MinFunction FunctionName="MinUnitPrice" ResultFormatString="{}{0:c}" SourceField="UnitPrice" /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
            <grid:GridViewDataColumn.Footer> 
                <Button Content="Show smallest UnitPrice" Click="Button_Click" Margin="5,0" /> 
            </grid:GridViewDataColumn.Footer> 
        </grid:GridViewDataColumn> 
        <grid:GridViewDataColumn Width="200" Header="Unit Price" TextAlignment="Right" DataMemberBinding="{Binding UnitPrice}" DataFormatString="{}{0:c}">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:SumFunction Caption="Sum: " ResultFormatString="{}{0:c}" SourceField="UnitPrice" /> 
                <data:AverageFunction Caption="Average: " ResultFormatString="{}{0:c}" SourceField="UnitPrice" /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
            <grid:GridViewDataColumn.Footer> 
                <StackPanel Orientation="Vertical" Margin="5,0">  
                    <TextBlock Text="Custom footer with aggregates:" Margin="0,0,0,2" /> 
                    <gridView:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" Grid.Column="4">  
                        <ItemsControl.ItemTemplate> 
                            <DataTemplate> 
                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">  
                                    <TextBlock VerticalAlignment="Center" Text="{Binding Caption}" /> 
                                    <TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" /> 
                                </StackPanel> 
                            </DataTemplate> 
                        </ItemsControl.ItemTemplate> 
                        <ItemsControl.ItemsPanel> 
                            <ItemsPanelTemplate> 
                                <StackPanel Orientation="Vertical" /> 
                            </ItemsPanelTemplate> 
                        </ItemsControl.ItemsPanel> 
                    </gridView:AggregateResultsList> 
                </StackPanel> 
            </grid:GridViewDataColumn.Footer> 
            <grid:GridViewDataColumn.GroupFooterTemplate> 
                <DataTemplate> 
 
                    <StackPanel Orientation="Vertical" Margin="5,0">  
                        <TextBlock Text="Custom footer with aggregates:" Margin="0,0,0,2" /> 
                        <gridView:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" Grid.Column="4">  
                            <ItemsControl.ItemTemplate> 
                                <DataTemplate> 
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">  
                                        <TextBlock VerticalAlignment="Center" Text="{Binding Caption}" /> 
                                        <TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" /> 
                                    </StackPanel> 
                                </DataTemplate> 
                            </ItemsControl.ItemTemplate> 
                            <ItemsControl.ItemsPanel> 
                                <ItemsPanelTemplate> 
                                    <StackPanel Orientation="Vertical" /> 
                                </ItemsPanelTemplate> 
                            </ItemsControl.ItemsPanel> 
                        </gridView:AggregateResultsList> 
                    </StackPanel> 
                </DataTemplate> 
 
            </grid:GridViewDataColumn.GroupFooterTemplate> 
        </grid:GridViewDataColumn> 
        <grid:GridViewDataColumn Width="200" Header="Date" DataMemberBinding="{Binding Date}" DataFormatString="{}{0:d}" TextAlignment="Right">  
            <grid:GridViewDataColumn.AggregateFunctions> 
                <data:MinFunction Caption="Min: " ResultFormatString="{}{0:d}" SourceField="Date" /> 
                <data:MaxFunction Caption="Max: " ResultFormatString="{}{0:d}" SourceField="Date" /> 
            </grid:GridViewDataColumn.AggregateFunctions> 
        </grid:GridViewDataColumn> 
    </grid:RadGridView.Columns> 
</grid:RadGridView> 
 

Vlad
Telerik team
 answered on 27 Nov 2009
1 answer
123 views

Hi,

I have a form that uses the rad gridview control. I have 4 text boxes for a user to key in information about a telephone number. Once they click an add button, I place the information into the rad gridview and clear the 4 text boxes. The user then can enter another telephone number and repeat this process as much as necessary.

The data in the rad gridview is not persisted to the database until the user clicks the save button.

When the user clicks the save button, I want to loop through each row in the rad gridview and gather the information and insert it into the database.

How can I accomplish this task? I was trying to use syntax like this:

For Each item In Me.GridTelephone.Items

// gather the 4 values for the telephone for this item

// and insert it into the database

Next

but the .Items collection of the rad gridview is an IList. This means I cannot determine the type of the data in each row such as a string, integer, boolean, and so on.

How can I determine the type of each item as I loop through them. For example:

public class telephone

IsDefault as boolean

Number as string

Country as integer

End Class

dim phone as new Telephone()

For Each item In Me.GridTelephone.Items

// boolean

phone.IsDefault = item ???

// string

phone.Number = item ???

// integer

phone.Country = item ???

Next

So     again, I want to loop through the items and assign the values to a local class which has types.

How can I perform this task?

Bill

Vlad
Telerik team
 answered on 27 Nov 2009
3 answers
168 views
I just installed Q3 RadControls for WPF demo with VS2008 Pro on Windows 7.  I am attempting to follow along with

http://tv.telerik.com/wpf/radgridview/getting-started-with-radgridview-for-wpf

and am hitting an error immediately.  When I drag the RadGradView from the Toolbox onto the Design window, I receive a lengthy error dialog:

'Telerik.Windows.Controls.GridView;;;Component\Themes\GenericOfficeBlack.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'.  '/Teleric.Windows.Controls.GridView;component/themes/office/black/GridViewToggleButton.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'.
Object reference not set to an instance of an object.  Error at object 'System.Windows.ResourceDictionary' in markup file 'Telerik.Windows.Controls.GridView;;;Component\Themes\GenericOfficeBlack.xaml'.  Error at object 'System.Windows.ResourceDictionary'.

(This is a fresh install of VS 2008 Pro ... I haven't tried anything else with this config, and no other Telerik demos are presently installed.)

Any ideas what might be causing this?  Did I miss an install step of some kind? 

Thanks!

Valerio Giorgi
Top achievements
Rank 1
 answered on 26 Nov 2009
2 answers
112 views
I have a NumericUpDown control inside a cell of a GridView.  When you type a number then hit the up or down the NumericUpDown control increments or decrements repeatedly based on the up or down key.
Boyan
Telerik team
 answered on 26 Nov 2009
3 answers
971 views
Hi guys,

I've set up some columns which are of Decimal data type with a data format string which converts these decimals values to a percentage between 0 - 100% ie. DataFormatString = "{0.0.00\\%}". The problem I am having is a few of these rows do not need to have the data format string on them, they should be left as they are. I've had a look at conditional formatting with Converters with the ContentStringFormat but can't get this to work (I believe because the data type is decimal?). I am using the decimal type because this helps with validation (only numerics). Otherwise, what's the best method to implement this?

Thanks!

Tim.

This is the code I used for the converter:

XAML

<

 

telerikGrid:RadGridView.Resources>

 

 

 

<Client:ValueConverter x:Key="ValueConverter"/>

 

 

 

<Style TargetType="{x:Type telerik:GridViewCell }">

 

 

 

<Setter Property="ContentStringFormat" Value="{Binding Path=Period,Converter={StaticResource ValueConverter}}"/>

 

 

 

</Style>

 

 

 

</telerikGrid:RadGridView.Resources>

 


Binding Path=Period is a <BindingList> of Decimals so 'object value' returns an array of objects, which I have to extract. Basically my goal is to overwrite (or bypass) the DataFormatString in the GridViewDataColumn for a few rows - if this is possible.

Converter Class

public

 

object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

 

{

 

//if (a[0] > 100)

 

 

return "{0:0.00}";

 

 

//return Binding.DoNothing;

 

}


Tsvyatko
Telerik team
 answered on 26 Nov 2009
3 answers
115 views
Hello.
I evaluate GridView and try to use custom row layout as it showed in GridView/CustomRowLayout.
I created ControlTemplate and placed GridViewCell for every column. But these cells is not editable, have gray background color and do not use expected representation (for example boolean property is diplayed as True/False string instead of checkbox).
How to display cells as they are displayed without any custom row layout?
Kalin Milanov
Telerik team
 answered on 26 Nov 2009
1 answer
123 views
Hi,
How Can I set a image in to specific cell on all selected rows.
i tried something like this:
foreach (MyObject obj in MyGrid.SelectedItems) 
System.Windows.Controls.Image image = new System.Windows.Controls.Image(); 
        image.Source = new BitmapImage(new Uri(@"[...]")); 
        ((MyObject)MyGrid.SelectedItem).myImageimage

the problem with this code is that the last row is the only row effected.
Milan
Telerik team
 answered on 26 Nov 2009
1 answer
159 views
Hi! Is there a way to remove the header? I just want ContentTemplate. And, how can override the MouseDoubleClick event? T don't want the resize animation. I just want to catch, wich item have been selected.

Thank.

Daniel
Tihomir Petkov
Telerik team
 answered on 25 Nov 2009
1 answer
59 views
hello all,

i upgraded to q3 version. however, since then, i am having problems with scrolling. though i have set scrolling to realtime, it does not behave so. also the form hangs or freezes very often and whenever its refreshed. 
is this a known behaviour?

since i was having troubles with q3, i downgraded to q2 - 2009.2.813.35
i am trying to align group totals to left hand side. i am pasting part of the code here. however, i still donot get group totals on the left hand side. i know that q3 has fixed this issue but becoz of above mentioned issues, i am unable to use them. 

please can u let me know if i am doing ath wrong in the code below.

 <Window.Resources>
        <Style x:Key="GridViewGroupRowStyle1" TargetType="GridView:GridViewGroupRow">
            <Setter Property="HorizontalAlignment" Value="Left"/>
           
        </Style>
    </Window.Resources>
        
      
        <telerik:RadGridView x:Name="WipGrid" 
                             MultipleSelect="True" 
                             
                             CanUserReorderColumns="True"
                             CanUserResizeColumns="True"
                             CanUserSortColumns="True"
                             ValidationMode="Cell"   
                             MouseDoubleClick="WipGrid_MouseDoubleClick"
                             Grouping="WipGrid_Grouping"
                             ScrollMode="RealTime" GroupRowStyle="{StaticResource GridViewGroupRowStyle1}" >
Kalin Milanov
Telerik team
 answered on 25 Nov 2009
1 answer
42 views
The GroupFooters appear not to be correctly updating their width all the time.
ie.  Grab the ColumnHeader sizing thumb and drag it narrower, and the GroupFooter doesn't change to match.  Dragging it wider however, appears to work.

I've tested with last release 2009.3.1103.35 and 2009.3.1120.35

There was nothing special in my XAML, just showing columns automatically.

<telerik:RadGridView xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"   
            ShowGroupFooters="True" 
            x:Name="uxRadGridView">  
</telerik:RadGridView> 
 
Kalin Milanov
Telerik team
 answered on 25 Nov 2009
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?