Telerik Forums
UI for WPF Forum
1 answer
1.1K+ views

i have created a derived class from telerik:RadGridView. i need to styling the cells based on the data. so that i have created a styling class and use it as cellstyleselector for columns. i need to sett column cell style for each column and i used the below code but it does not work. do you have any idea of why it does not works?

public class WPFGridConv:RadGridView
{
public WPFGridConv()
    {
        this.ShowGroupPanel = false;
        this.Loaded += WPFGridConv_Loaded;
        this.AutoGeneratingColumn += WPFGridConv_AutoGeneratingColumn;
        this.ValidationType = GridViewValidationType.None;
        this.ValidatesOnDataErrors= GridViewValidationMode.InViewMode;
 
    }
 
    private void WPFGridConv_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
    {
        CreateHeader();
    }
 
 
    public void WPFGridConv_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        CreateHeader();
 
    }
 
    private void CreateHeader()
    {
 
        foreach (Telerik.Windows.Controls.GridViewColumn column in this.Columns)
        {
 
                column.CellStyleSelector= new GridStyleSelector();
 
        }
    }
}
 
public class GridStyleSelector : StyleSelector
{
 
    public override Style SelectStyle(object item, DependencyObject container)
    {
        if (container is GridViewCell)
        {
            GridViewCell cell = container as GridViewCell;
            string columnId = cell.Column.Tag.ToString();
            WPFGridConv grid = cell.ParentOfType<WPFGridConv>();
            List<InputClass.GridColumnInfoClass> columnsInfoList = grid.workingGridClass.ListOfColumnsInfo;
            InputClass.GridColumnInfoClass columnInfo = columnsInfoList.Find(x => x.id == columnId);
            Type columnType = columnInfo.typeOfColumn;
            if ((cell.Value==null||string.IsNullOrEmpty(cell.Value.ToString())) && columnInfo.IsValueNecessary)
            {
                return NeedeValueStyle;
            }
            else
            {
                if (columnType == null || columnType == typeof(double))
                {
                    double dummyDbl;
                    if (!double.TryParse(cell.Value.ToString(), out dummyDbl))
                        return BadInputStyle;
                    else
                        return CorrectValueStyle;
                }
                else if (columnType == typeof(int))
                {
                    int dummyInt;
                    if (!int.TryParse(cell.Value.ToString(), out dummyInt))
                        return BadInputStyle;
                    else
                        return CorrectValueStyle;
                }
                return CorrectValueStyle;
            }
        }
        return null;
    }
 
    public Style OutOfRangeStyle
    {
        get
        {
            Style returnStyle=new Style(typeof(GridViewCell));
            returnStyle.Setters.Add(new Setter(GridViewCell.BorderBrushProperty, new SolidColorBrush(Colors.Purple)));
            return returnStyle;
        }
        set
        {
 
        }
    }
 
    public Style BadInputStyle {
        get
        {
            Style returnStyle = new Style(typeof(GridViewCell));
            returnStyle.Setters.Add(new Setter(GridViewCell.BorderBrushProperty, new SolidColorBrush(Colors.Red)));
            return returnStyle;
        }
        set
        {
 
        }
    }
 
    public Style NeedeValueStyle
    {
        get
        {
            Style returnStyle = new Style(typeof(GridViewCell));
            returnStyle.Setters.Add(new Setter(GridViewCell.BorderBrushProperty, new SolidColorBrush(Colors.IndianRed)));
            return returnStyle;
        }
        set
        {
 
        }
    }
    public Style CorrectValueStyle
    {
        get
        {
            Style returnStyle = new Style(typeof(GridViewCell));
            returnStyle.Setters.Add(new Setter(GridViewCell.BorderBrushProperty, new SolidColorBrush(Colors.Black)));
            return returnStyle;
        }
        set
        {
 
        }
    }
}

i have created a derived class from telerik:RadGridView. i need to styling the cells based on the data. so that i have created a styling class and use it as cellstyleselector for columns. i need to sett column cell style for each column and i used the below code but it does not work. do you have any idea of why it does not works?

Dilyan Traykov
Telerik team
 answered on 08 Feb 2017
3 answers
185 views

this is what I do

1- right click on a rad desktop alert(with windows 8 touch theme) and select edit template->edit a copy

2- name the new style as "newstyle"

3- set the DesktopAlertStyle property of DAP(DesktopAlertParameters) to this style

4- set the ShowMenuButton property of DAP(DesktopAlertParameters) to false

4- alertmanager.ShowAlert(DAP)

 

now the alert that is shown has all the style that it has to have BUT it shows the Menubutton eventhough it shouldn't! and even if we set the showmenubutton property to true and add a couple of menus, after this styling those menus are not shown it seems that there is no binding between the dropdownbutton in the header and the properties of desktopalertitem itself

Kalin
Telerik team
 answered on 08 Feb 2017
4 answers
191 views

Hi, I am using Telerik RadScheduleView in my WPF projet.

How to remove / disable the cross  for delete schedule (cross in the right corner schedule / appointment)

and how to adjust the height of the time schedule?

 

Thanks

 

Kiena
Top achievements
Rank 1
 answered on 08 Feb 2017
0 answers
125 views

I have an app with scores of .xaml files, and dozens of xaml fields that are in turn bound to dozens of backing properties.  Right now, this is all a flat namespace.  Each xaml represents a “UserControl” (one UserControl per xaml). 

A problem is that every backing property (dozens) lives in a single object.  I want to control specific backing properties using specific classes.  For instance, I might want the Admin page xaml fields to all be bound to an Admin object while the Status area fields might be bound to a Status object. 

How can I do this?    Right now, I only have the option of binding every field in the xaml's to a single name space.

For instance, I want to say something like:

File: UC_AdminView.xaml:  --- bind the fields here to the AdminView backing object
<UserControl x:Class="Gui.View.UC_AdminView"
… >
<StackPanel x:Name="AppInfo">
                    <Label Content="{Binding AdminView.AppName}" 
              …     />

...

 

- and - 

File: UC_StatusArea.xaml:  --- bind the fields here to the StatusArea backing object
<UserControl x:Class="Gui.View.UC_StatusArea"

… >
<StackPanel x:Name="StatusStuff">
                    <Label Content="{Binding StatusArea.Name}" 
              …     />

David
Top achievements
Rank 1
 asked on 07 Feb 2017
2 answers
175 views

I would like to add some transparency to the vertical trackball line style.

Thanks.

 

Reilly
Top achievements
Rank 1
Veteran
 answered on 07 Feb 2017
2 answers
132 views

I need to bind hundreds of thousands of objects to TreeListView, potentially up to ~1-1.5 million at peak. Right now on my test set binding 350k of those objects takes 15-20 seconds. Is there any way to achieve at most a few seconds performance?

I am working with existing data structure that is not homogeneous: root rows in my tree are objects, child roots are their fields which could also be potentially objects. They also can cross-reference each other, so creating all the structure at once would lead to endless recursion, that's why child rows are only created when the root is expanded. I don't think this actually matters much in this case, as I am talking about hundreds of thousands of root rows, they will be collapsed by default and expanded only one by one.

But this means I have a slim wrapper around my initial data to create a class suitable for TreeListView binding which makes data homogeneous. There are only 5 columns/properties, and creating all of those objects and a bindable collection of them only takes ~1 second in my code, it seems that the rest is spent "pushing" data to UI.

Another important thing is I just need to display a "snapshot" with that much data, it's static, there will be no changes to the collection, only manual editing of cells values user can perform (wrapper implements INotifyPropertyChanged). I tried adding a range of items at once with suspended notifications, recreating bindable collection from a previously prepared list each time it's loaded, but they all seem to offer the same 15-20 secs performance on a 350k set. Even then scrolling, roots expanding and filtering performance is terrible.

I was looking at VirtualQueryableCollectionView, but as I understand, it doesn't work with local data, for example, from a list? Pagination is also something I was looking at, but then search/filtering only works within current page. Is there anything else I can do to make it faster?

Martin
Telerik team
 answered on 07 Feb 2017
7 answers
507 views

Hello,

I am using the RadPropertyGrid EditorAttribute to define the editor for a property. Currently, I only have the ability to pass the TargetProperty to my editor through this attribute. However, I would like to be able to pass some extra properties such as filters (not necessarily through binding).

 My current code looks like this:

[Telerik.Windows.Controls.Data.PropertyGrid.Editor(typeof(MultipleTagsEditorPreview), "Value", Telerik.Windows.Controls.Data.PropertyGrid.EditorStyle.None)]
public ObservableCollection<TagConfiguration> Tags {get;set;} //Full block removed for brevity

What I would like to do is something like this:

[Telerik.Windows.Controls.Data.PropertyGrid.Editor(typeof(MultipleTagsEditorPreview), "Value", Telerik.Windows.Controls.Data.PropertyGrid.EditorStyle.None, "Filter1,Filter2,Filter3")]
 public ObservableCollection<TagConfiguration> Tags { get;set;}
 

For obvious reasons, I can't create a new editor for every combination of filters. I think it might be easier to inherit the EditorAttribute class and override it to contain a Filters property and have my own constructor that calls the base constructor. But I am not sure how to pass my properties to the editor once it has been instantiated by the RadPropertyGrid. Is there some behavior that I can override to do this? For example:

MultipleTagsEditorPreview editor = Activator.CreateInstance(this.EditorType);
editor.Filters = this.Filters; //this is where I would pass the filters to my editor
return editor;

 

Any help would be appreciated,

Thanks

 

Stefan Nenchev
Telerik team
 answered on 07 Feb 2017
1 answer
244 views

Hello,

I need help for changing WPF RadGridView Row Color Based on checkbox event.

Since Radgrdiview has more than 1000 records most of the record are invisible,

so due to virtualization below code is not working , row color changes when user scroll grdiview

   this.userGridView.CurrentCell.ParentRow.Background = Brushes.Red;

 

RadGridView of the screen is created dynamically and in the grid one of column is containing checkboxes.

Based on requirements row color of checkboxes which are checked are green and unchecked check box row color are grayed.

If one of the unchecked check box is marked as check from user its row should change to "Red" and if again unchecked it should be "Dark Gray".

I need help to code dynamically from xaml.cs

 

Please find below code snippet which I have tried.

 this.AddHandler(CheckBox.CheckedEvent, new RoutedEventHandler(CheckBoxChecked));
  private void CheckBoxChecked(object sender, RoutedEventArgs e)
        {
            if (userGridView.CurrentCell != null)
            {
              ?????????????
            }
        }

Dilyan Traykov
Telerik team
 answered on 07 Feb 2017
1 answer
205 views

Hello Telerik,

 

I'm using RadGanttView and I want to change the main customtask color. Actually, it is Orange (default).

I know is it possible to Hilight all of Summarys Tasks (my target), but Hilight is Red, and I don't know how I can change his color.

 

Which way is better ? Change the Hilighted Task Color or apply a color for my custom task ?

 

The CustomMainTask (Summary Task) is created like this :

var task = new CustomGanttTask();
task.Start = variableAffichee.dateDebut;
task.End = variableAffichee.dateFin;
task.Title = viewModel.ListeVariables.Find(v => v.Id == variableAffichee.idVariable).Code.ToString(); //variable = une tâche principale variableAffichee.codeVariable
task.TitreColonne = task.Title;
task.Description = task.Title; // this.viewModel.ListeVariables.Find(v => v.Id == variableAffichee.idVariable).Code.ToString();
task.BackgroundColor = new SolidColorBrush(new Color { A = 0, R = 0, G = 170, B = 0 }); //System.Windows.Media.Brushes.SteelBlue;               

But the last line, BackgroundColor hasn't got any effect on the task. This is the same problem for Description and Title properties.

 

The CustomTask Class  :

public class CustomGanttTask : GanttTask
    {
        public Brush BackgroundColor { get; set; }
 
        public string Affectation { get; set; }
 
        public int IdCommentaire { get; set; }
 
        public string TitreColonne { get; set; }
    }

 

I attached a screenshot to show you my result.

 

Can you help me ?

 

Thank you !

Dilyan Traykov
Telerik team
 answered on 07 Feb 2017
2 answers
244 views

Hi Telerik,

 

When setting a Dock Panel's IsActive property to true, the Panel will "slide" out over top of all other active windows, even if the application is not "Active" or has been minimized. The effect is that the sliding effect will show even when the application is minimized and other applications are active (i.e. Microsoft Word, etc.) and it can become disruptive. Could you please let us know if this is the intended behavior? We'd like the behavior of when setting IsActive to true, to not show the sliding effect when the application is not active or has been minimized.

Is there a property we can set so that the Panel does not appear as "top-most" when setting the Panel's IsActive property to true?

Please advise.

 

Kind regards.

 

Abhinav
Top achievements
Rank 1
 answered on 06 Feb 2017
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
Slider
Expander
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
WebCam
CardView
DataBar
Licensing
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
HighlightTextBlock
Security
TouchManager
StepProgressBar
VirtualKeyboard
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?