Telerik Forums
UI for WPF Forum
0 answers
80 views
Hi,

I need to disable editing of cells but be able to insert row. With my current property settings:

CanUserInsertRows="True" 
IsReadOnly="False" 

It is not possible to insert row while the grid is readonly.

What is the best way of achieving what I want?
Mark
Top achievements
Rank 1
 asked on 27 Aug 2012
0 answers
76 views
Hi,

Is it possible to insert a new row above the selected item? Just like inserting a new row in Excel.
Mark
Top achievements
Rank 1
 asked on 27 Aug 2012
5 answers
362 views
How do you modify the RollOver Colors for a ComboBox, are there properties that need to be exposed in order to do this. Or can the RollOver be Disabled in the event you can't modify the colors?
Regards.
Masha
Telerik team
 answered on 27 Aug 2012
2 answers
105 views
Hello,

I am having trouble keeping the text value after the dropdown closes when nothing is selected.

I populate the text property with a value that is not in the ItemsSource.  If a user clicks the dropdown to expand it and then closes the dropdown without selecting an item, the text is set to null.

I populate the EmptyText property with the value of text hoping that would keep it from becoming empty but that does not work.  I also caught the dropdownclosed event thinking that if the SelectedItem was null I would repopulate the text.  This did not matter because at that point the text is still populated.

Can you please throw me an idea?

Thanks,

Jason
Vladi
Telerik team
 answered on 27 Aug 2012
1 answer
201 views
Can you provide an example of a data bound Bubble Chart using the new RadChartView controls? I have seen a few examples using the old RadChart controls but none as of yet using RadChartView.

Thanks,

Mark
Petar Marchev
Telerik team
 answered on 27 Aug 2012
1 answer
51 views

Using the example class for serializing gridview (RadGridViewSettings) I am running into a problem, everything is great but when we attemt to LoadLayout for a gridview with groupdescriptors we get pixelWidth err every time. What could be the problem?

I know your going to say use the persist fw classes but we have special needs including that our grid filters are in a raddatafilter and there can be many settings files per gridview per each datafilter configuration and it is only partial saved in this way and some in our database too so our existing class works perfect and took a long time to develop... except if there is a groupdescriptor... we get this error.


Error:

Message: The parameter value must be greater than zero.
Parameter name: pixelWidth
 
Source: PresentationCore
 
Trace:    at System.Windows.Media.Imaging.RenderTargetBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat)
   at Telerik.Windows.Controls.FrameworkElementToImageConverter.ToImage(FrameworkElement element) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Common\FrameworkElementToImageConverter.cs:line 26
   at Telerik.Windows.Controls.GridView.GridViewGroupPanel.ConvertFrameworkElementToImage(FrameworkElement frameworkElement) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Grouping\GridViewGroupPanel.cs:line 185
   at Telerik.Windows.Controls.GridView.GridViewGroupPanel.GetEffectiveContentForDescriptor(IGroupDescriptor descriptor) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Grouping\GridViewGroupPanel.cs:line 177
   at Telerik.Windows.Controls.GridView.GridViewGroupPanel.PrepareContainerForItemOverride(DependencyObject element, Object item) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Grouping\GridViewGroupPanel.cs:line 144
   at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
   at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
   at System.Windows.Controls.Panel.AddChildren(GeneratorPosition pos, Int32 itemCount)
   at System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
   at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
   at System.Windows.Controls.ItemContainerGenerator.OnItemAdded(Object item, Int32 index)
   at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
   at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
   at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\RadObservableCollection.cs:line 235
   at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\ObservableItemCollection.cs:line 91
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Data\Collections\RadObservableCollection.cs:line 281
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at NciDataTools.RadGridViewSettings.LoadState() in C:\..........\classes\ClassRadGridSettings.cs:line 275
   at NciDataTools.WindowMain.gridScheduleUserSettingsLoad() in C:\..........\WindowMain.xaml.cs:line 1369
   at NciDataTools.WindowMain.gridScheduleRefreshDataChanges() in C:\..........\WindowMain.xaml.cs:line 1345
   at NciDataTools.WindowMain.gridScheduleDataWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) in C:\..........\WindowMain.xaml.cs:line 1640
   at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
   at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)


Happens at this point (GroupDescriptors.Add(d)) when loading from the xml file.



if
(Settings.GroupSettings.Count > 0)
{
grid.GroupDescriptors.Clear();
foreach (GroupSetting setting in Settings.GroupSettings)
{
ColumnGroupDescriptor d = new ColumnGroupDescriptor();
d.Column = (from c in grid.Columns.OfType<GridViewBoundColumnBase>()
where c.GetDataMemberName() == setting.PropertyName
select c).FirstOrDefault();
d.SortDirection = setting.SortDirection;
grid.GroupDescriptors.Add(d);
}
}
Vlad
Telerik team
 answered on 27 Aug 2012
0 answers
173 views
I want to manage the width of GridViewDataColumn in my viewmodel. I can bind GridViewDataColumn.Width to a viewmodel property to set the width in the view. I also want to send the GridViewDataColumn.ActualWidth to the viewmodel, but ActualWidth is read-only so doesn't support binding. For FrameworkElements there is a solution described here: http://stackoverflow.com/questions/1083224/pushing-read-only-gui-properties-back-into-viewmodel but GridViewDataColumn is not a FrameworkElement.

Is there a way to get the ActualWidth to the viewmodel when a user resizes a column? Is there an event that is triggered when a user resizes a column?
Erik
Top achievements
Rank 1
 asked on 26 Aug 2012
1 answer
98 views
I have a small window with an RRTB and its associated RadRichTextBoxRibbonUI.  

The RRTB has initial focus, and the caret is blinking at the top left.

If the user changes the font from the default, say from Verdana to Times New Roman, then clicks anywhere within the RRTB as if they were bringing focus back to it, the font changes back to the default (Verdana in this example).

Attached is an image with three stills taken 1) on load 2) after font change and 3) after click.

Is this expected behavior, or a bug?  Are there any workarounds for it?
Todor
Telerik team
 answered on 24 Aug 2012
1 answer
175 views
I'm trying to complete a toolbar-based font size editor for the RRTB.  

I'm trying to emulate the behavior of the ribbon-based editor's font size combo.  It displays the font size of the size of the span where the cursor is located.  I can do this by listening to CurrentSpanStyleChanged (as recommended elsewhere in the forum),  I can then grab the CurrentEditingStyle and update the current font size.

var style = steRTB.CurrentEditingStyle;
SelectedFontSize = (double)_conv.ConvertBack(
                       style.GetPropertyValue(TSpan.FontSizeProperty),
                       typeof(double), null, null);


Its a little bit wonky, I know, but its the only way I know of now to keep my currently displayed font size in sync.

The problem arises when there is a selection.  The correct way to display the current font size when there exist multiple font sizes within a selection is to show no font size.  The ribbon UI does this.  I'm trying to emulate this, however I can't figure out how to tell when 

1. A selection event has triggered CurrentSpanStyleChanged
2. How to determine the font sizes for each span within the selection

How can I do this?  Or how should I be keeping track of the current font size, if I'm totally off?
Nikolay Demirev
Telerik team
 answered on 24 Aug 2012
1 answer
283 views
I am using the RADGridView for the manipulation of data, the data has a number of "week" blocks which consist of 3 columns, i have been using columngroups to create a header for each week block.  The number of week blocks, and therefore columns in the grid, is variable so a dynamic object is used at the item source and the columns generated in the "AutoGeneratingColumn" event, as are the column groups.  The issue is that not all the column groups are being displayed once the grid has been generated, i have checked the properties of the group to check each column has its correct column group and it does.

See the code below (it's a cut down version of the actual code but it produces the same result)

<Window x:Class="ColumnGroupsExample.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <DataTemplate x:Key="dtMainResource">
            <TextBlock Text="{Binding Path=MainResourceType}" />
        </DataTemplate>
        <DataTemplate x:Key="dtAdjustedCost">
            <TextBlock Text="{Binding Path=AdjustedCost, StringFormat=C}" HorizontalAlignment="Right" Padding="0,0,4,0" />
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <telerik:RadGridView Grid.Row="0"
                            CanUserDeleteRows="False" 
                            CanUserInsertRows="False" 
                            CanUserSortColumns="False"
                            ShowGroupPanel="False"
                            AutoGeneratingColumn="RadGridView_AutoGeneratingColumn"
                            ItemsSource="{Binding Rows}"
                            RowIndicatorVisibility="Collapsed"  
                            AlternateRowBackground="White"
                            AlternationCount="2"
                            Background="AliceBlue"
                            EditTriggers="None"
                            HorizontalGridLinesBrush="SlateGray"
                            SelectionMode="Single"
                            SelectionUnit="FullRow"
                            ShowColumnHeaders="True"
                            IsFilteringAllowed="False"
                            VerticalGridLinesBrush="Transparent"
                             FrozenColumnCount="1">
            <telerik:RadGridView.ColumnGroups>
                <telerik:GridViewColumnGroup Name="Type" Header="Type" />
                <telerik:GridViewColumnGroup Name="Monthly" Header="Monthly" />
            </telerik:RadGridView.ColumnGroups>
        </telerik:RadGridView>
    </Grid>
</Window>

Code behind

 

namespace ColumnGroupsExample
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using Telerik.Windows.Data;
    using Telerik.Windows.Controls;
  
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private ViewModel _viewModel;
  
        public MainWindow()
        {
            InitializeComponent();
  
            _viewModel = new ViewModel();
            this.DataContext = _viewModel;
        }
  
        private void RadGridView_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
        {
            if (e.Column.UniqueName.Contains("Week"))
            {
                if (e.Column.UniqueName.EndsWith("CostPlan"))
                {
                    DataTemplate costPlanDT = new DataTemplate();
  
                    FrameworkElementFactory spCostPlan = new FrameworkElementFactory(typeof(DockPanel));
                    spCostPlan.SetValue(DockPanel.LastChildFillProperty, false);
  
                    FrameworkElementFactory costPlanEntry = new FrameworkElementFactory(typeof(TextBox));
  
                    costPlanEntry.SetBinding(TextBox.TextProperty, new Binding(e.Column.UniqueName)
                    {
                        NotifyOnSourceUpdated = true,
                        UpdateSourceTrigger = UpdateSourceTrigger.LostFocus,
                        StringFormat = "F2"
                    });
  
                    costPlanEntry.SetValue(TextBox.FontSizeProperty, 10.0);
                    costPlanEntry.SetValue(TextBox.HorizontalContentAlignmentProperty, HorizontalAlignment.Right);
  
                    costPlanEntry.SetValue(TextBox.WidthProperty, 80D);
                    spCostPlan.AppendChild(costPlanEntry);
  
                    costPlanDT.VisualTree = spCostPlan;
                    costPlanDT.Seal();
  
                    e.Column.Header = "Cost Plan";
                    e.Column.CellTemplate = costPlanDT;
                    e.Column.Width = 88;
  
                    int weekNumber = System.Convert.ToInt32(e.Column.UniqueName.Replace("Week", "").Replace("CostPlan", ""));
  
                    ((RadGridView)sender).ColumnGroups.Add(new GridViewColumnGroup()
                    {
                        Name = e.Column.UniqueName.Replace("CostPlan", ""),
                        Header = string.Format("Week : {0} - {1}",
                                                weekNumber,
                                                DateTime.Now.AddDays((weekNumber - 1) * 7).ToString("dd/MM/yyyy"))
                    });
  
                    e.Column.ColumnGroupName = e.Column.UniqueName.Replace("CostPlan", "");
                }
                else if (e.Column.UniqueName.EndsWith("AssessedCost"))
                {
                    DataTemplate assessedCostDT = new DataTemplate();
  
                    FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(DockPanel));
                    spFactory.SetValue(DockPanel.LastChildFillProperty, false);
  
                    FrameworkElementFactory assessedCostsEntry = new FrameworkElementFactory(typeof(TextBox));
  
                    assessedCostsEntry.SetBinding(TextBox.TextProperty, new Binding(e.Column.UniqueName)
                    {
                        NotifyOnSourceUpdated = true,
                        UpdateSourceTrigger = UpdateSourceTrigger.LostFocus,
                        StringFormat = "F2"
                    });
  
                    assessedCostsEntry.SetValue(TextBox.FontSizeProperty, 10.0);
                    assessedCostsEntry.SetValue(TextBox.HorizontalContentAlignmentProperty, HorizontalAlignment.Right);
                    assessedCostsEntry.SetValue(TextBox.WidthProperty, 80D);
  
                    spFactory.AppendChild(assessedCostsEntry);
  
                    assessedCostDT.VisualTree = spFactory;
                    assessedCostDT.Seal();
  
                    e.Column.Header = "Assessed Cost";
  
                    e.Column.CellTemplate = assessedCostDT;
                    e.Column.Width = 88;
                    e.Column.ColumnGroupName = e.Column.UniqueName.Replace("AssessedCost", "");
                }
                else if (e.Column.UniqueName.EndsWith("Difference"))
                {
                    DataTemplate differenceDt = new DataTemplate();
  
                    FrameworkElementFactory difference = new FrameworkElementFactory(typeof(TextBlock));
  
                    difference.SetBinding(TextBlock.TextProperty, new Binding(e.Column.UniqueName)
                    {
                        StringFormat = "C"
                    });
  
                    difference.SetValue(TextBlock.FontSizeProperty, 10.0);
                    difference.SetValue(TextBlock.PaddingProperty, new Thickness(0, 0, 4, 0));
  
                    difference.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right);
  
                    difference.SetValue(TextBlock.WidthProperty, 80D);
  
                    differenceDt.VisualTree = difference;
                    differenceDt.Seal();
  
                    e.Column.Header = "Difference";
  
                    e.Column.CellTemplate = differenceDt;
                    e.Column.ColumnGroupName = e.Column.UniqueName.Replace("Difference", "");
  
                }
                else if (e.Column.UniqueName.EndsWith("CF03DetailDateUid"))
                {
                    //Don't show this column
                    e.Column.IsVisible = false;
                }
            }
            else
            {
                if (e.Column.UniqueName == "MainResourceType")
                {
                    e.Column.CellTemplate = (DataTemplate)this.Resources["dtMainResource"];
                    e.Column.Header = "Resource Type";
                    e.Column.ColumnGroupName = "Type";
                }
                else if (e.Column.UniqueName == "Projection")
                {
                    DataTemplate projectionDT = new DataTemplate();
  
                    FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(DockPanel));
                    spFactory.SetValue(DockPanel.LastChildFillProperty, false);
  
                    FrameworkElementFactory projectionEntry = new FrameworkElementFactory(typeof(TextBox));
  
                    projectionEntry.SetBinding(TextBox.TextProperty, new Binding(e.Column.UniqueName)
                    {
                        NotifyOnSourceUpdated = true,
                        UpdateSourceTrigger = UpdateSourceTrigger.LostFocus,
                        StringFormat = "F2"
                    });
  
                    projectionEntry.SetValue(TextBox.FontSizeProperty, 10.0); ;
                    projectionEntry.SetValue(TextBox.StyleProperty, (Style)this.Resources["detailEntry"]);
                    projectionEntry.SetValue(TextBox.HorizontalContentAlignmentProperty, HorizontalAlignment.Right);
                    projectionEntry.SetValue(TextBox.WidthProperty, 80D);
  
                    spFactory.AppendChild(projectionEntry);
  
                    projectionDT.VisualTree = spFactory;
                    projectionDT.Seal();
                    e.Column.CellTemplate = projectionDT;
  
                    e.Column.Header = "Projection";
                    e.Column.ColumnGroupName = "Monthly";
                }
                else if (e.Column.UniqueName == "AdjustedCost")
                {
                    //#FFCCFFFF
                    e.Column.CellTemplate = (DataTemplate)this.Resources["dtAdjustedCost"];
                    e.Column.Header = "Adjusted Costs";
                    e.Column.ColumnGroupName = "Monthly";
                }
            }
        }
    }
}

View Model

namespace ColumnGroupsExample
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Dynamic;
    using System.Collections.ObjectModel;
    using System.Windows.Input;
  
    public class ViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private ObservableCollection<dynamic> _rows;
  
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        protected void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
  
        public ViewModel()
        {
            _rows = new ObservableCollection<dynamic>();
  
            CreateRow("Staff");
            CreateRow("Labour");
            CreateRow("Plant");
            CreateRow("Temp Materials");
            CreateRow("Perm Materials");
            CreateRow("Sub Contract");
        }
  
        public void CreateRow(string type)
        {
            var row = new ExpandoObject() as IDictionary<string, Object>;
  
            decimal zero = 0;
            Guid? blankUid = Guid.Empty;
  
            row.Add("MainResourceType", type);
            row.Add("AdjustedCost", zero);
            row.Add("Projection", zero);
  
            for (int i = 1; i <= 13; i++)
            {
                row.Add(string.Format("Week{0}CostPlan", i), zero);
                row.Add(string.Format("Week{0}AssessedCost", i), zero);
                row.Add(string.Format("Week{0}Difference", i), zero);
                row.Add(string.Format("Week{0}CF03DetailDateUid", i), blankUid);
            }
  
            _rows.Add(row);
        }
  
        public ObservableCollection<dynamic> Rows
        {
            get
            {
                return _rows;
            }
            set
            {
                if (_rows != value)
                {
                    _rows = value;
                    OnPropertyChanged("Rows");
                }
            }
  
        }
    }
}

 

 

 


Please advise on how to get the column groups displaying correctly.

Cheers

Steve


Pavel Pavlov
Telerik team
 answered on 24 Aug 2012
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?