Telerik Forums
UI for WPF Forum
0 answers
131 views

I have a custom GridView inherited from ‘RadGridView’ which is binded to generic list.

Some of the rows in the gridview is becoming readonly(Edited values are getting restored to older value when curser moved to next position) while editing(not all rows).

Please help

Custom grid view

------------

public enum EquipmentList

    {

        Unknown,

        StowList,

        DischargeList,

        RestowList,

        HandList,

        StowedList,

        ProcessList

    }

   

    public class EquipmentsGridView : RadGridView

    {

        public EquipmentList ListType { get; set; }

        private ObservableCollection<EquipmentInformation> _source;

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "By design")]

        public IList<EquipmentInformation> Source

        {

            get

            {

                return _source;

            }

            set

            {

                if (_source != null)

                {

                    _source.CollectionChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_source_CollectionChanged);

                }

                base.ItemsSource = _source = new ObservableCollection<EquipmentInformation>(value);

                _source.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_source_CollectionChanged);

                ResetNumbers();

                ApplyBehavior();

            }

        }

        public bool IsEdited { get; set; }

        public EquipmentsGridView()

        {

            base.CellValidating += GridView_CellValidating;

            base.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(EquipmentsGridView_SelectionChanged);

        }

        void EquipmentsGridView_SelectionChanged(object sender, SelectionChangeEventArgs e)

        {

            if (this.Items.IsAddingNew || this.Items.IsEditingItem)

            {

                this.CommitEdit();

            }

        }

        private void ApplyBehavior()

        {

            foreach (var column in base.Columns)

            {

                if (column is GridViewBoundColumnBase)

                {

                    column.ShowDistinctFilters = false;                

                }

            }

        }

        void EquipmentsGridView_CellValidated(object sender, GridViewCellValidatedEventArgs e)

        {

            if (e.Cell.ParentRow.Item != null)

            {

                if (((EquipmentInformation)e.Cell.ParentRow.Item).IsCanceled)

                {

                    e.Cell.Foreground = Brushes.White;

                    e.Cell.Background = Brushes.Red;

                    e.Cell.FontStyle = FontStyles.Oblique;

                }

                else

                {

                    e.Cell.Foreground = Brushes.Black;

                    e.Cell.Background = Brushes.White;

                    e.Cell.FontStyle = FontStyles.Normal;

                }

            }

        }

        void _source_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

        {

            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||

                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||

                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)

            {

                ResetNumbers();

                IsEdited = true;

            }

        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Editing need to be in lowercase")]

        private void GridView_CellValidating(object sender, Telerik.Windows.Controls.GridViewCellValidatingEventArgs e)

        {

            if (e.OldValue != e.NewValue)

            {

                ((System.Windows.Controls.TextBox)(e.EditingElement)).Text = e.NewValue.ToString().ToLower(System.Globalization.CultureInfo.InvariantCulture);

                IsEdited = true;

            }

        }

    }

Geo
Top achievements
Rank 1
 asked on 01 Feb 2012
1 answer
192 views
Hello,

Is there a way to remove the title bar on the RadRibbonView, or hide it?  Or at least some way to not have '- My Application' in the title bar text?

Thank you
Petar Mladenov
Telerik team
 answered on 01 Feb 2012
1 answer
86 views
I have a Usercontrol that I use as my cell's DataTemplate (actually I stick it directly into my controltemplate, but shouldn't make a difference)

I have a DependencyProperty that is bound to the Value of the cell, and the changed-listener looks like this

public static void TextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            double dub;
            if (e.OldValue != null && e.NewValue != null && (e.NewValue is double || (e.NewValue is string && double.TryParse(e.NewValue.ToString(), out dub))))
            {  
                var control = o as ValueCellPresenter;
 
                if (control.IsLoaded)
                {
                    ((Storyboard)control.Resources["CellFlash"]).Begin();
                }
 
            }
             
        }

however, this animation fires when I am scrolling, because of UI virtualization.

I use this animation to flash the cell when the value changes.  Is there a better way to do this to avoid getting the animation fired when UI virtualization is in effect?  When I turn the virtualization off the problem goes away.
Vlad
Telerik team
 answered on 01 Feb 2012
1 answer
85 views
Hello,
I started a new project and using your OpenAccess library just as you did in "WPF MVVM with OpenAccess" sample solution form OpenAccess SDK. AddCommand works fine when I add a single record. But when I try to add multiple records, ViewModel saves only recent inserted item. How do I savе multiple new records?
Thank you.
PetarP
Telerik team
 answered on 31 Jan 2012
2 answers
384 views
Hello,
I have a Category class which contains Categories property which is a List<Category>. I use MVVM with your OpenAccess ORM. Here is a XAML markup I use to bind tree to data:
<telerik:RadTreeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="CategoryTree" ItemsSource="{Binding Path=Categories}" SelectedItem="{Binding Path=CurrentCategory, Mode=TwoWay}" SelectionChanged="CategoryTree_SelectionChanged">
                                <telerik:RadTreeView.ItemTemplate>
                                    <HierarchicalDataTemplate ItemsSource="{Binding Categories}">
                                        <TextBlock Text="{Binding Name}" />
                                    </HierarchicalDataTemplate>
                                </telerik:RadTreeView.ItemTemplate>
                            </telerik:RadTreeView>

In CategoryViewModel I have the following method:
protected override void Load()
        {
            _categories = new ObservableCollection<CategoryBO>();
            foreach (Category category in _repositoryCategory.Entities.Where(p => p.ParentCategory == null))
            {
                CategoryBO tempCategory = category;
                if (tempCategory != null)
                {
                    Categories.Add(tempCategory);
                }
            }
            _categoryView = CollectionViewSource.GetDefaultView(Categories);
            OnPropertyChanged("CategoriesList");
            OnPropertyChanged("CurrentCategory");
        } and this is how I initialize a CategoryBO object:
 public static implicit operator CategoryBO(Category category)
        {
            return new CategoryBO(category);
        }
public CategoryBO(Category category)
        {
            ID = category.CategoryID;
            ParentID = category.ParentID;
            Name = category.Name;
            foreach (ProductBO product in category.Products)
            {
                _products.Add(product);
            }

            foreach (Category cat in category.Categories)
            {
                _categories.Add(cat);
            }
        }
As you can see, I iterate through root level categories and they all have a Categories property filled with data. But when I try to select child categories from tree, they select visually on the tree but SelectedItem is always null. This happens because in Load() method I have CollectionViewSource.GetDefaultView(Categories) which returns a list which contains only root categories. 
How do get SelectedItem?
Thank you.
PetarP
Telerik team
 answered on 31 Jan 2012
2 answers
82 views
Hi --

I'm trying to add some SpellChecker capabilities to a RadGridView.  I'm currently auto-generating the columns in the GridView because it's not a fixed object type that will be displayed in the list. 

I am looking for a way to either:
  • Have the spell checker work when columns are auto-generated (just apply it to all columns)
  • Programmatically add columns to the gridview (MVVM pattern) by using reflection on an object.  With any luck, I would be able to use a custom DataAnnotation to indicate whether to use spell check on the generated column.  Also could maybe use a different annotation for the column heading?? 

Let me know your thoughts -- it would be really cool to get this to work.

Thanks in advance.
Erik
Top achievements
Rank 2
 answered on 31 Jan 2012
3 answers
167 views
Is it possible to use a DataTemplate for a GridView columns collection?
I want to define my columns once and use it in multiple views
Maya
Telerik team
 answered on 31 Jan 2012
5 answers
224 views
Hi,

in my application I have a RadGridView for who I create his columns dynamically on a specific event in my application. For each row in this grid, I need a sub grid. To achieve this, I create a GridViewToggleRowDetailsColumn dynamically.
 
In my XAML, I defined a <telerik:RadGridView.RowDetailsTemplate><DataTemplate><telerik:RadGridView x:Name="subSetGrid".

If I want to create dynamically the columns of my "subSetGrid" and assign it's "DataSource" to simething, how I can do to achieve this???

Thank's 
Rossen Hristov
Telerik team
 answered on 31 Jan 2012
2 answers
157 views
We have used Radgrid view and have fixed width of columns.ON double click of the row content we open a tab.
 When we stretch or increase the column width at runtime, it does show the complete bind text and after we double click the extended portion of the row, it does not get the event.
Following is the code example used

<telerik:GridViewDataColumn

                            ShowDistinctFilters="False"

                            Width="250"

                            >

                            <telerik:GridViewColumn.Header>

                                <TextBlock

                                    Text="Role Name"

                                    Style="{StaticResource HeaderTextBlockStyle}"

                                    >

                                </TextBlock>

                            </telerik:GridViewColumn.Header>

                            <telerik:GridViewColumn.CellTemplate>

                                <DataTemplate>

                                    <TextBlock

                                        Text="{Binding Path=RoleName}"

                                        TextTrimming="CharacterEllipsis"

                                        Width="250"

                                        >

                                        <TextBlock.ToolTip>

                                            <ToolTip

                                                Content="{Binding Path=RoleName}"

                                                Background="{StaticResource BlueBrush}"

                                                Style="{StaticResource ToolTipStyle}"

                                                >

                                            </ToolTip>

                                        </TextBlock.ToolTip>

                                    </TextBlock>

                                </DataTemplate>

                            </telerik:GridViewColumn.CellTemplate>

                        </telerik:GridViewDataColumn>

Bhakti
Top achievements
Rank 1
 answered on 31 Jan 2012
5 answers
123 views
using version 2011 Q1
I have a window with a tree view and a grid
when I change the selected item in the tree i run query, build an ObservableCollection and bind it to the ItemSource of the grid.
all grid columns are Width="Auto"
the problem is that when i rebind the ItemSource, the width of columns don't update correctly, actually they don't update at all.
sometimes a column in the the resulting collection has 200 characters at most, other times 25 characters at most.
the columns width does not re size to correctly to 25 characters, it is left at 200 characters, the columns have too much white-space.
is the grid not supposed to do update the columns when the ItemSource gets a new collection?
if not how can I force the columns to adjust to current data collection.
as in one of your examples i have tried to iterate the grid.Columns setting the width to Auto, nothing happened.

your help would be much appreciated.
thanks






Yordanka
Telerik team
 answered on 31 Jan 2012
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
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?