Telerik Forums
UI for WPF Forum
1 answer
499 views

Hi, 

I am using a RadGridView to bind a DataTable. In that table I have dynamically generated columns. That's why I chose to set AutoGenerateColumns=true. 

I am now looking for a way to style the cells in depending on the properties of the object within the cell of the DataTable.

What I tried until now:

The first method seem the most promissing to me, so here is some code for that:


<UserControl.Resources>
        <Style x:Key="PilotStyle"
               TargetType="telerik:GridViewCell">
            <Setter Property="Background"
                    Value="Magenta" />
        </Style>
        <Style x:Key="ExpansionStyle"
               TargetType="telerik:GridViewCell">
            <Setter Property="Background"
                    Value="Aqua" />
        </Style>
        <valueConverters:RodTimeTypeConverter x:Key="converter" />
        <local:RodTableCellStyleSelector x:Key="selector"
                                         ConditionConverter="{StaticResource converter}">
            <local:RodTableCellStyleSelector.Rules>
                <local:ConditionalStyleRule Style="{StaticResource PilotStyle}">
                    <local:ConditionalStyleRule.Value>
                        <system:Boolean>True</system:Boolean>
                    </local:ConditionalStyleRule.Value>
                </local:ConditionalStyleRule>
                <local:ConditionalStyleRule Style="{StaticResource ExpansionStyle}">
                    <local:ConditionalStyleRule.Value>
                        <system:Boolean>False</system:Boolean>
                    </local:ConditionalStyleRule.Value>
                </local:ConditionalStyleRule>
            </local:RodTableCellStyleSelector.Rules>
        </local:RodTableCellStyleSelector>
    </UserControl.Resources>


<telerik:RadGridView  Grid.Row="1"
                                  CanUserSortColumns="False"
                                  CanUserSelectColumns="False"
                                  CanUserReorderColumns="False"
                                  CanUserDeleteRows="False"
                                  CanUserGroupColumns="False"
                                  CanUserSelect="False"
                                  IsFilteringAllowed="False"
                                  ShowColumnSortIndexes="False"
                                  ShowGroupPanel="False"
                                  RowHeight="45"
                                  AutoGeneratingColumn="GridViewDataControl_OnAutoGeneratingColumn"
                                  ItemsSource="{Binding RodTimesTable.DefaultView}">
                <telerik:RadGridView.Resources>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="FontSize"
                                Value="20" />
                    </Style>

                </telerik:RadGridView.Resources>
            </telerik:RadGridView>


public class RodTableCellStyleSelector : StyleSelector
    {
        public override Style SelectStyle(object item, DependencyObject container)
        {
            var conditionValue = this.ConditionConverter.Convert(item, null, null, null);
            foreach (var rule in this.Rules.Where(rule => Equals(rule.Value, conditionValue)))
            {
                return rule.Style;
            }

            return base.SelectStyle(item, container);
        }

        List<ConditionalStyleRule> rules;
        public List<ConditionalStyleRule> Rules
        {
            get
            {
                return this.rules ??= new List<ConditionalStyleRule>();
            }
        }

        public IValueConverter ConditionConverter { get; set; }
    }
    public class ConditionalStyleRule
    {
        public object Value { get; set; }

        public Style Style { get; set; }
    }



private void GridViewDataControl_OnAutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
        {
            var grid = (RadGridView)sender;
            var dataGrid = (grid.ItemsSource as DataView)?.Table;
            e.Column.Header = dataGrid?.Columns[e.Column.Header.ToString()].Caption;
            if (e.Column.Header != null && (e.Column.Header.ToString().StartsWith("Pilot") || e.Column.Header.ToString().StartsWith("Expansion")) )
            {
                e.Column.CellStyleSelector = (StyleSelector)this.FindResource("selector");
            }
        }

I would really appreciate any help.

 

Thanks in advance.

Stenly
Telerik team
 answered on 31 Mar 2023
1 answer
117 views

Hi,

What I'm tryin to do is create an App that starts hidden (without a RadWindow) and when you click on a context menu of NotifyIcon it shows a RadWindow. I've tried several options and none work correctly.

What would be the best approach for this scenario?

 

Thanks

Martin Ivanov
Telerik team
 answered on 30 Mar 2023
0 answers
128 views
We are using RadSemicircleNorthGauge and RadProgressBar, and we would like to update the look and feel, but I don't really know what changes have been made since 2017.   Perhaps there are new controls we should use or updated properties on the existing ones.  Can you point me to the right place to get this information?
Brett
Top achievements
Rank 1
 asked on 29 Mar 2023
1 answer
378 views

In my MainWindow I am using a RadDocking container for displaying 3 RadSplitContainer. My problem is that I cannot set the size of those RadSplitContainers correctly.

I set the HasDocumentHost property of the RadDocking to False.

I tried setting the ProportionalStackPanel.RelativeSize property on each of my RadPaneGroups. These settings get completely ignored.

Here is my MainWindow.xaml code:


<DockPanel>
        <views:MenuBarView DataContext="{Binding MenuBar}" DockPanel.Dock="Top"/>
        <telerik:RadDocking Name="radDocking" HasDocumentHost="False">
                <telerik:RadSplitContainer HorizontalContentAlignment="Stretch"
                                        InitialPosition="DockedLeft">
                    <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="200,600">
                        <telerik:RadPane Header="{helpers:SwitchBinding DirtyBit, Pages*, Pages}" telerik:RadDocking.SerializationTag="PagesPane"
                                        CanUserClose="False" CanUserPin="False" >
                            <views:PagesView DataContext="{Binding PagesViewModel}" />
                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="DockedTop">
                    <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="400,400">
                        <telerik:RadPane Header="{helpers:SwitchBinding DirtyBit, Editor*, Editor}" Name="MainEditor"
                                    CanUserClose="False" CanUserPin="False">
                            <views:EditorView DataContext="{Binding Editor}" />
                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
                <telerik:RadSplitContainer InitialPosition="DockedBottom">
                    <telerik:RadPaneGroup telerik:ProportionalStackPanel.RelativeSize="400,200">
                        <telerik:RadPane Header="Info" Name="Output" CanUserClose="False" CanUserPin="False">
                            <views:InfoView DataContext="{Binding InfoViewModel}"/>
                        </telerik:RadPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
        </telerik:RadDocking>
    </DockPanel>

The result looks something like shown in MainWindow_Layout.PNG. But I would like a layout (and I would have guessed that my ProportionalStackPanel.RelativeSize properties set this behavior) like the one shown in MainWindow_Layout_desired.PNG.

How can I set the RadSplitContainers' relative size correctly?

Philipp
Top achievements
Rank 1
Iron
 answered on 29 Mar 2023
1 answer
256 views

Today I tried to put a context menu on a row in a RadGridView that would operate on the row clicked.  I was surprised to find it was not nearly as trivial as I expected.  All the documentation on this is either very old or accomplishing it via code or code-behind.  The "official" demo even has an entry for "Row Context Menu", which sounds tantalizingly close until one looks at the code.  It's certainly not MVVM!

This should be as simple as the following:

<telerik:RadGridView ItemsSource="{Binding Path=MyRecords}">
    <telerik:RadContextMenu.ContextMenu>
        <telerik:RadContextMenu >
            <telerik:RadMenuItem Header="Do something to this record" Command="{Binding MyRowCommand}" CommandParameter="{Binding ?????}" />
        </telerik:RadContextMenu>
    </telerik:RadContextMenu.ContextMenu>
	...
</telerik:RadGridView>

The problem is that I can't for the life of me figure out what to pass as the command parameter that will help me identify the row.

Any help would be much appreciated!

Martin Ivanov
Telerik team
 answered on 29 Mar 2023
1 answer
155 views
I customized my WPF app's Windows8Touch theme with a compete palette of colors -- that is I set up the Windows8TouchPalette at startup before the main windows shows.  In my palette, the background is dark and the foreground is light. 

I've had it this way for years and it works quite well.  But the whenever I set the RadToolTipService.ToolTipContent property on  any control using just a string, I get a white background fpr tje text.  So I am forced to specifically create a full UI for it or use the ToolTipContentTemplate.   It looks like the default settings for that do not honor my colors

Is there some Telerik-specific control type that I can set a default style for that will fix this issue?  Kinda like how I can style `RadAlert` or `RadPrompt` for those dialogs?

(Note that I am using the binaries with XAML in them so I use the StyleManager to theme things, if that matters.  Where I feel the need I copy the Telerik styles out of your XAML files for my theme and customize them. )
Martin Ivanov
Telerik team
 answered on 29 Mar 2023
1 answer
168 views

Hi,

I need to export a chart to pdf without displaying it as part of a background task. Right now I'm having an issue where the chart appears blank when passed through the image saving process I've seen on your demo's. Looking at the code, it has all the values it needs it just isn't being built since it isn't displayed. Is there any way around this?

Thanks,

Frank

Martin Ivanov
Telerik team
 answered on 28 Mar 2023
1 answer
563 views

Hi,

I'm working with a GridView where some Editing cells are a lot wider than the Cell. The GridView resize correctly to fit the editing mode but doesn't resize correctly when edit is completed.

I tried to set the Column Width to Auto, in the GridView and individually in each column, but the calculation for optimal width seems to be chaotic and triggered but some other actions on the GridView.

Is there a way in code behind to iterate through each column and trigger a width calculation?

 

Thank you for your help

Vladimir Stoyanov
Telerik team
 answered on 28 Mar 2023
0 answers
157 views
Hello, I am using Radspreadsheet for WPF. I need once I import data, I attach checkbox at the last column in each row.
This is what I have done so far:

            
    int rowCount = importxls.ActiveWorksheet.UsedCellRange.RowCount;
                int lastcolumn = importxls.ActiveWorksheet.UsedCellRange.ColumnCount;

                MessageBoxResult result = MessageBox.Show(rowCount.ToString());

                // Create a new checkbox and set its properties
                CheckBox checkbox = new CheckBox();
                checkbox.IsChecked = true;
                checkbox.VerticalAlignment = VerticalAlignment.Center;
                checkbox.Margin = new Thickness(5, 0, 0, 0);

                DependencyProperty chkBox = DependencyProperty.Register(
                      "Select", typeof(bool), typeof(CheckBox),
                      new UIPropertyMetadata(checkbox.IsChecked));

                for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
                {
                    
                    // Add the checkbox to the current row
                    RowSelection rowSelection = importxls.ActiveWorksheet.Rows[rowIndex];
                    CellIndex cellIndex = new CellIndex(rowIndex, lastcolumn);
                    CellSelection cellSelection = rowSelection.Worksheet.Cells[cellIndex];

                    cellSelection.SetValue(DateTime.Now); //checkbox should be here

                }


Where am I supposed to modify?
Cheruiyot
Top achievements
Rank 1
 asked on 27 Mar 2023
1 answer
137 views

I just started to work with the ScheduleView, so maybe this is a newbie question.

I want to create an appointment after I have selected a timerange in the ScheduleView (on MouseUp). I need the corresponding resources to be set, but apart from that only start and end should be set on the new appointment.

Should I involve the DragDropManager or can it be solved with events on the ScheduleView only?

Best regard

Ola Nygren

Stenly
Telerik team
 answered on 24 Mar 2023
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
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
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
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
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?