Telerik Forums
UI for WPF Forum
1 answer
70 views

 

if (this.radGridView_A1.SelectedRecords.Count() == 0)


does not compile with the latest (q3) wpf dlls

 

Rossen Hristov
Telerik team
 answered on 30 Dec 2009
5 answers
218 views
I have to grid views (one is my medialibrary and one for a playlist). I want to drag songs from the "medialibrary" to the "playlist", I aslo need to be adle to insert anywhere on the "playlist" grid when I drag from "medialib".

Also need to dragdrop within the "playlist" so I can change place on the songs in the "playlist".

Now I only get drag from "medialib" to "playlist" work sort of, and the tooltip looks funny.

Help!

C#
ObservableCollection<Song> _mediaLib;     
ObservableCollection<Song> _playlist;     
    
    
private void InitGrids()     
        {     
            _mediaLib = new ObservableCollection<Song>();     
            _playlist = new ObservableCollection<Song>();     
    
            radGridViewMediaLib.ItemsSource = _mediaLib;     
            radGridViewPlaylist.ItemsSource = _playlist;     
    
            RadDragAndDropManager.AddDropQueryHandler(radGridViewMediaLib, OnDropQuery);     
            RadDragAndDropManager.AddDropQueryHandler(radGridViewPlaylist, OnDropQuery);     
    
            RadDragAndDropManager.AddDragQueryHandler(radGridViewMediaLib, OnOrderDragQuery);     
            RadDragAndDropManager.AddDragQueryHandler(radGridViewPlaylist, OnOrderDragQuery);     
    
            RadDragAndDropManager.AddDragInfoHandler(radGridViewMediaLib, OnOrderDragInfo);     
            RadDragAndDropManager.AddDragInfoHandler(radGridViewPlaylist, OnOrderDragInfo);     
        }   
  
  
#region DragDrop     
    
        private void OnDropQuery(object sender, DragDropQueryEventArgs e)     
        {     
            // We allow drop only if the dragged items are products:     
            ICollection draggedItems = e.Options.Payload as ICollection;     
            bool result = draggedItems.Cast<object>().All((object item) => item is Song);     
            e.QueryResult = result;     
            e.Handled = true;     
    
            // Note that here we agree to accept a drop. We will be notified     
            // in the DropInfo event whether a drop is actually possible.     
        }     
    
        private void OnOrderDragQuery(object sender, DragDropQueryEventArgs e)     
        {     
            RadGridView gridView = sender as RadGridView;     
            if (gridView != null)     
            {     
                IList selectedItems = gridView.SelectedItems.ToList();     
                e.QueryResult = selectedItems.Count > 0;     
                e.Options.Payload = selectedItems;     
            }     
    
            e.QueryResult = true;     
            e.Handled = true;     
        }     
    
        private void OnOrderDragInfo(object sender, DragDropEventArgs e)     
        {     
            RadGridView gridView = sender as RadGridView;     
            IEnumerable draggedItems = e.Options.Payload as IEnumerable;     
    
            if (e.Options.Status == DragStatus.DragInProgress)     
            {     
                //Set up a drag cue:     
                TreeViewDragCue cue = new TreeViewDragCue();     
                //Here we need to choose a template for the items:     
                cue.ItemTemplate = this.Resources["Song"as DataTemplate;     
                cue.ItemsSource = draggedItems;     
                e.Options.DragCue = cue;     
            }     
            else if (e.Options.Status == DragStatus.DragComplete)     
            {     
                IList source = gridView.ItemsSource as IList;     
                foreach (object draggedItem in draggedItems)     
                {     
                    _playlist.Add((Song)draggedItem);     
                }     
            }     
        }   
  
        #endregion     
    
    
private ObservableCollection<Song> GetSongs(int count)     
        {     
            ObservableCollection<Song> _sList = new ObservableCollection<Song>();     
    
            for (int i = 0; i < count; i++)     
            {     
                Song _s = new Song();     
                _s.Artist = "Artist " + i.ToString();     
                _s.Title = "Title " + i.ToString();     
                _s.GUID = Guid.NewGuid();     
                _sList.Add(_s);     
            }     
    
    
            return _sList;     
        }     
    
    
//Song class     
public class Song     
    {     
        public Song()     
        {     
                
        }     
    
        public Guid GUID { getset; }     
        public string Artist { getset; }     
        public string Title { getset; }     
    
    }     
 


WPF:
<Window.Resources> 
        <Style TargetType="gridViewElements:GridViewRow" x:Key="OrderItemStyle">  
            <Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" /> 
        </Style> 
 
        <LinearGradientBrush x:Key="DropPossibleBackground" StartPoint="0 0" EndPoint="0 1">  
            <GradientStop Offset="0" Color="White" /> 
            <GradientStop Offset="1" Color="#FFE699" /> 
        </LinearGradientBrush> 
 
    </Window.Resources> 
 
<telerik:RadGridView Height="762" Margin="12,42,571,-42" Name="radGridViewMediaLib" Width="595" HorizontalAlignment="Left" 
                             IsReadOnly="True" dragDrop:RadDragAndDropManager.AllowDrop="True" 
                        RowStyle="{StaticResource OrderItemStyle}" Background="White" 
                        CanUserFreezeColumns="False" CanUserInsertRows="False" 
                        ShowGroupPanel="False" /> 
              
 
        <telerik:RadGridView Height="762" Margin="0,50,64,-50" Name="radGridViewPlaylist" Width="480" HorizontalAlignment="Right"   
                             IsReadOnly="True" dragDrop:RadDragAndDropManager.AllowDrop="True" 
                        RowStyle="{StaticResource OrderItemStyle}" Background="White" 
                        CanUserFreezeColumns="False" CanUserInsertRows="False" 
                        ShowGroupPanel="False" /> 
Christophe
Top achievements
Rank 1
 answered on 30 Dec 2009
1 answer
68 views
hi
i would like to rollback the datetime user selection under the 'SelectedStartDateTimeChanged' event.
it seems that the SelectedDateTime property is updated correctly but the time control (view) is not.

scenario
the current dateTime selection is  29/12/2009 14:00
user try to change the datetime to  29/12/2009 15:00
then i would like from the time control to show 14:00 and not 15:00

source code:
 private void OnSelectedStartDateTimeChanged(object sender, RoutedPropertyChangedEventArgs<DateTime?> e)
        {
            try
            {
                UnSubscribeToSelectedStartDateTimeChanged();
                if (e.OldValue == null) //first time loading
                    return;

                 startDateTime.SelectedDateTime = (DateTime) e.OldValue;
              
            }
            finally
            {
                SubscribeToSelectedStartDateTimeChanged();
            }
        }
Kaloyan
Telerik team
 answered on 30 Dec 2009
2 answers
233 views
I'm trying to use the RadGridView AggregateFunctions. I've tested Count, Min and Max functions successfully. However, when I try using SumFunction or AverageFunction, nothing is displayed on the column footer (including the previously added Count, Min, Max functions).

I'm binding a DataTable to the grid from C# like this:

this.radGrid1.ItemsSource = dtData; 

This is the XAML for the GridView:

<telerikGrid:RadGridView  
            x:Name="radGrid1" 
            MultipleSelect="True"  
            AutoGenerateColumns="False" 
            ShowColumnFooters="True" ShowGroupFooters="True"
 
            <telerikGrid:RadGridView.Columns> 
                 
                <telerikGrid:GridViewDataColumn Header="AccountNo" DataMemberBinding="{Binding AccountNo}"
                    <telerikGrid:GridViewDataColumn.AggregateFunctions> 
                        <telerikData:CountFunction Caption="Count:" /> 
                    </telerikGrid:GridViewDataColumn.AggregateFunctions> 
                </telerikGrid:GridViewDataColumn> 
                 
                <telerikGrid:GridViewDataColumn Header="InvestmentCost" DataMemberBinding="{Binding InvestmentCost}" DataFormatString="{}{0:c}" TextAlignment="Right"
                    <telerikGrid:GridViewDataColumn.AggregateFunctions> 
                        <telerikData:SumFunction ResultFormatString="{}{0:c}" SourceField="InvestmentCost" /> 
                        <telerikData:MinFunction ResultFormatString="{}{0:c}" SourceField="InvestmentCost" /> 
                        <telerikData:MaxFunction ResultFormatString="{}{0:c}" SourceField="InvestmentCost" /> 
                    </telerikGrid:GridViewDataColumn.AggregateFunctions> 
                </telerikGrid:GridViewDataColumn> 
                 
            </telerikGrid:RadGridView.Columns> 
        </telerikGrid:RadGridView> 

Edit: 
DataType for InvestmentCost column in dtData is Decimal.
I'm using RadControls for WPF Q3 2009 SP1
Jeffrey
Top achievements
Rank 1
 answered on 30 Dec 2009
1 answer
42 views
hello i have the rad gridview in my project and i need too diffrent color for rows

for example 
1 row     Blue
2 row   yello

3 row     Blue
4 row   yello

5 row     Blue
6 row   yello

and....
Missing User
 answered on 29 Dec 2009
3 answers
198 views
I am looking for a way to make the gridview go directly into edit mode when the cell is clicked on.  I also need the up and down arrow to move the selected row/cell
Stefan Dobrev
Telerik team
 answered on 29 Dec 2009
4 answers
148 views
Hello, from what I understood based on the previous threads here, the DragEnter, DragOver, Drop... events from
Ziad
Top achievements
Rank 1
 answered on 29 Dec 2009
3 answers
322 views
I don't know if it is something we are doing wrong or if it the control itself.

When you open several nodes the process hits levels of 40%-50%.

I ran the profiler while viewing the TreeView. It shows that the node expanders are continually refreshing.

I'm deducting that the loading animation begins but does not stop. It looks like the screen is refreshing even in when the animation's visibility is not visible. I don't know if it is a fact that the screen is trying to refresh because of the loading animation, but it seems like it.

In the template, the trigger is defined:

<Trigger Property="IsLoadingOnDemand" Value="True"
                    <Trigger.EnterActions> 
                        <BeginStoryboard> 
                            <Storyboard> 
                                <DoubleAnimation Duration="00:00:01" RepeatBehavior="Forever" Storyboard.TargetName="LoadingVisualAngleTransform" Storyboard.TargetProperty="Angle" From="0" To="359"/> 
                            </Storyboard> 
                        </BeginStoryboard> 
                    </Trigger.EnterActions> 
                     
                    <Setter Property="Visibility" TargetName="LoadingVisual" Value="Visible"/> 
                    <Setter Property="Visibility" TargetName="Expander" Value="Collapsed"/> 
                </Trigger> 

If what I stated above is true, wouldn't you need to add and ExitAction like:
<Trigger Property="IsLoadingOnDemand" Value="True"
                    <Trigger.EnterActions> 
                        <BeginStoryboard> 
                            <Storyboard x:Name="NodeLoadingStoryboard"
                                <DoubleAnimation Duration="00:00:01" RepeatBehavior="Forever" Storyboard.TargetName="LoadingVisualAngleTransform" Storyboard.TargetProperty="Angle" From="0" To="359"/> 
                            </Storyboard> 
                        </BeginStoryboard> 
                    </Trigger.EnterActions> 
                     
                    <Trigger.ExitActions> 
                        <StopStoryboard BeginStoryboardName="NodeLoadingStoryboard" /> 
                    </Trigger.ExitActions> 
                     
                    <Setter Property="Visibility" TargetName="LoadingVisual" Value="Visible"/> 
                    <Setter Property="Visibility" TargetName="Expander" Value="Collapsed"/> 
                </Trigger> 



Have you seen this behavior? Am I missing something?

Thanks


Miroslav
Telerik team
 answered on 28 Dec 2009
3 answers
262 views
I have a stacked area chart set up with multiple series. The source of the data is an observable collection. When I add items to the observable collection, the chart does not update. When I bind the data directly without using multiple series, it updates fine. How can I get this working?

        private ObservableCollection<ChartPoint> _kw1;
        private ObservableCollection<ChartPoint> _kw2;

        private Timer _timer;

        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            _timer = new Timer(TimerCallback, null,TimeSpan.Zero, TimeSpan.FromSeconds(1));

            RadChart1.DefaultView.ChartArea.AxisX.IsDateTime = true;

            _kw1 = new ObservableCollection<ChartPoint>();

            _kw2 = new ObservableCollection<ChartPoint>();

            var seriesList = new List<ObservableCollection<ChartPoint>> { _kw1, _kw2 };

            var lineDefinition1 = new StackedAreaSeriesDefinition();
            var lineDefinition2 = new StackedAreaSeriesDefinition();

            var series1 = new SeriesMapping { LegendLabel = "Paint Line", CollectionIndex = 0, SeriesDefinition = lineDefinition1 };
            series1.ItemMappings.Add(new ItemMapping { DataPointMember = DataPointMember.YValue, FieldName = "Kw" });
            series1.ItemMappings.Add(new ItemMapping { DataPointMember = DataPointMember.XValue, FieldName = "Timestamp" });

            var series2 = new SeriesMapping { LegendLabel = "Fan 1", CollectionIndex = 1, SeriesDefinition = lineDefinition2 };
            series2.ItemMappings.Add(new ItemMapping { DataPointMember = DataPointMember.YValue, FieldName = "Kw" });
            series2.ItemMappings.Add(new ItemMapping { DataPointMember = DataPointMember.XValue, FieldName = "Timestamp" });

            var seriesMappings = new SeriesMappingCollection {series1, series2};

            RadChart1.SeriesMappings = seriesMappings;
            RadChart1.ItemsSource = seriesList;
        }

        private void TimerCallback(object o)
        {
            Debug.WriteLine("Updating...");

      if(!Dispatcher.CheckAccess())
      {
                Dispatcher.Invoke(new ThreadStart(() => TimerCallback(null)));
          return;
      }

            _kw1.Add(new ChartPoint{ Kw = (new Random()).Next(0, 10), Timestamp = DateTime.Now});
            _kw2.Add(new ChartPoint { Kw = (new Random()).Next(0, 10), Timestamp = DateTime.Now });
        }
Velin
Telerik team
 answered on 28 Dec 2009
4 answers
168 views
Are there any plans to port the RadRotator control (my favourite) to WPF or SilverLight? I'm relatively new to WPF, so maybe there's a methodology for easily re-creating this effect that I am not familiar with.
Art Kedzierski
Top achievements
Rank 2
 answered on 28 Dec 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?