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.
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

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?
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!


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

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

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
}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