Telerik Forums
UI for WPF Forum
16 answers
3.3K+ views
Hi guys,

   I'm a WPF developer, and I'm looking for some sample code that will show me how to set the radGridView row background color based on the value of a column in the row. Do you have an example that will do so?
   Specifically, I want to set a row's background color to Red if the value of Due_Date is within 1 day of today, and to Yellow if it's between 2 and 3 days from today.

Thanks,

Les
Claudio
Top achievements
Rank 1
 answered on 03 Sep 2013
3 answers
518 views
How do I create summary rows in wpf . We are switching our windows form project to wpf and we are doing this in winforms:

var actualInItem = new GridViewSummaryItem("ActualIn", "{0:C}", GridAggregateFunction.Sum);<br>                var actualOutItem = new GridViewSummaryItem("ActualOut", "{0:C}", GridAggregateFunction.Sum);<br>                var grossItem = new GridViewSummaryItem("Gross", "{0:C}", GridAggregateFunction.Sum);<br>                var operatorShareItem = new GridViewSummaryItem("OperatorShare", "{0:C}", GridAggregateFunction.Sum);<br>                var CmsnLocationItem = new GridViewSummaryItem("CmsnLocation", "{0:C}", GridAggregateFunction.Sum);<br>                var overShortItem = new GridViewSummaryItem("OverShort", "{0:C}", GridAggregateFunction.Sum);<br>                var PayoutPercentage = new GridViewSummaryItem("PayoutPercentage", "Avg: {0:P1}", GridAggregateFunction.Avg);<br><br>                var summaryRowItem = new GridViewSummaryRowItem(<br>                    new[] { actualInItem, actualOutItem, grossItem, overShortItem, operatorShareItem, CmsnLocationItem, PayoutPercentage });<br><br><br>                template.SummaryRowsBottom.Add(summaryRowItem);

I can understand the aggregate functions can be done in my viewmodel but how do I add the summary row. Also, I have already used the row detail to display a child grid if that matters.
Dimitrina
Telerik team
 answered on 03 Sep 2013
3 answers
184 views
Hi!

Is is possible to get GridViewGroupPanelText to refresh when application culture changes? I have created custom resx (GridViewResources.en.resx and GridViewResources.resx) and it's working on initialization but does not change when the culture is changed during application execution.
 
I have added ResourceManager to .xaml.cs like this:

public BillingView()
{
     
    LocalizationManager.Manager = new LocalizationManager()
    {
        ResourceManager = GridViewResources.ResourceManager
    };
 
    InitializeComponent();
}

Br,

Kalle
Dimitrina
Telerik team
 answered on 03 Sep 2013
1 answer
116 views
Greetings.

The code below (see partial XAML and C#) display the grid of "Prospects".
Prospect's First, Last, and Middle name are GridViewDynamicHyperlinkColumn. User can click on one of those three columns and be redirected to the Prospect's edit form.
All this works perfectly until user decides to sort the grid (no matter which column).
After the grid has been sorted, clicking on First, Last, or Middle name has NO EFFECT.

Am I missing something?
If there is anything wrong, I certainly can't see it anymore.
Please help.

Thank you,

Frank M.

 

private void OnProspectGridUnLoaded(object sender, Telerik.Windows.Controls.GridView.RowUnloadedEventArgs e) {
    var row = e.Row as GridViewRow;
    if (row != null) {
        ((HyperlinkButton)row.Cells[0].Content).RemoveHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnProspectLinkClicked));
        ((HyperlinkButton)row.Cells[1].Content).RemoveHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnProspectLinkClicked));
        ((HyperlinkButton)row.Cells[2].Content).RemoveHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnProspectLinkClicked));
    }
}
 
private void OnProspectGridLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e) {
    var row = e.Row as GridViewRow;
    if (row != null) {
        ((HyperlinkButton)row.Cells[0].Content).AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnProspectLinkClicked), true);
        ((HyperlinkButton)row.Cells[1].Content).AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnProspectLinkClicked), true);
        ((HyperlinkButton)row.Cells[2].Content).AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnProspectLinkClicked), true);
    }
}
 
 
private void OnProspectLinkClicked(object sender, MouseButtonEventArgs e) {
    try {
        Type type = e.Source.GetType();
        if (type == typeof(System.Windows.Controls.ContentPresenter)) {
            DataRowView rowView = (DataRowView)((Telerik.Windows.Controls.GridView.GridViewCell)((((Telerik.Windows.Controls.GridView.HyperlinkButton)(sender)).Parent))).ParentRow.Item;
            DataRow selectedRow = (DataRow)rowView.Row;
            if (selectedRow != null && selectedRow[0] != DBNull.Value) {
                ProspectInformation.ProspectId = Convert.ToString(selectedRow["ProspectGuid"]);
                if (ProspectInformation.ProspectId != null && ProspectInformation.ProspectId != string.Empty) {
                    ((POWERPitch.Base.TabPanel)(((TabControl)parent).Parent)).IsFromHomePage = true;
                    ((POWERPitch.Base.TabPanel)(((TabControl)parent).Parent)).LinkName = Contexts.QuickLinkNames.OPEN_PROSPECT;
                    ((TabControl)parent).SelectedIndex = 2;
                }
            }
        }
    } catch (Exception ex) {
        IPMessageBox.ShowExceptionMessage("Exception in HomeForAgents.OnProspectLinkClicked " + ex.Message);
    }
}

 

<telerik:RadBusyIndicator DisplayAfter="0" x:Name="radBusyIndicator" Background="Transparent"
    HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
 
 <telerik:RadGridView Name="searchResultsGridView" EnableRowVirtualization="True" CanUserSortColumns="True"
    ColumnWidth="*" CanUserDeleteRows="False" IsReadOnly="True" IsFilteringAllowed="False" CanUserInsertRows="False"
    VerticalAlignment="Top" RowLoaded="OnSearchResultsGridLoaded" SelectionChanged="OnSearchResultsSelectionChanged"
    RowUnloaded="OnSearchResultsGridUnLoaded" Height="Auto" Width="Auto" Margin="5,3,5,0" Style="{StaticResource
    GridViewStyle}" HeaderRowStyle="{StaticResource HeaderStyle}" >
 
 <telerik:RadGridView.Columns>
 
     <telerik:GridViewDataColumn Name="createDateCol" Header="Last Updated" Width="Auto" DataMemberBinding="{Binding
        CreatedDate}" HeaderCellStyle="{StaticResource ColumnHeaderStyle}" CellStyle="{StaticResource
        gridcellStyle}"/>
 
     <telerik:GridViewDynamicHyperlinkColumn Name="lastNameCol" Header="Last Name" Width="Auto"
         DataMemberBinding="{Binding LastName}" HeaderCellStyle="{StaticResource ColumnHeaderStyle}"
        CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDynamicHyperlinkColumn Name="firstNameCol" Header="First Name" Width="Auto"
        DataMemberBinding="{Binding FirstName}" HeaderCellStyle="{StaticResource ColumnHeaderStyle}"
        CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="dateOfBrthCol" Header="Age" Width="Auto" DataMemberBinding="{Binding DOB}"
        HeaderTextAlignment="Center" TextAlignment="Center" HeaderCellStyle="{StaticResource ColumnHeaderStyle}"
        CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="genderCol" Header="G" Width="Auto" DataMemberBinding="{Binding Gender}"
        HeaderCellStyle="{StaticResource ColumnHeaderStyle}" CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="stateCol" Header="ST" Width="Auto" DataMemberBinding="{Binding StateCode}"
        HeaderCellStyle="{StaticResource ColumnHeaderStyle}" CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="quoteIdCol" Header="Quote/Illustration" Width="Auto"
        HeaderTextAlignment="Left"     TextAlignment="Left" DataMemberBinding="{Binding QuoteId}"
         HeaderCellStyle="{StaticResource ColumnHeaderStyle}" CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDynamicHyperlinkColumn Name="prodDescCol" Header="Product Summary" UniqueName="prodDescCol"
         DataMemberBinding="{Binding ProductDesc}" HeaderCellStyle="{StaticResource ColumnHeaderStyle}"
        CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="annPremCol" Header="Annual Premium" Width="Auto" DataMemberBinding="{Binding
        AnnualPremium}" HeaderTextAlignment="Right" TextAlignment="Right" HeaderCellStyle="{StaticResource
        ColumnHeaderStyle}" CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="agntCdCol" Header="Agent Code" Width="Auto" DataMemberBinding="{Binding
        AgentCode}" HeaderTextAlignment="Right" TextAlignment="Right" HeaderCellStyle="{StaticResource
        ColumnHeaderStyle}" CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="agntNameCol" Header="Agent Name" Width="Auto" DataMemberBinding="{Binding
        AgentName}" HeaderCellStyle="{StaticResource ColumnHeaderStyle}" CellStyle="{StaticResource gridcellStyle}"/>
 
     <telerik:GridViewDataColumn Name="gaCodeCol" Header="GA Code" Width="Auto" DataMemberBinding="{Binding GACode}"
         HeaderTextAlignment="Right" TextAlignment="Right" HeaderCellStyle="{StaticResource ColumnHeaderStyle}"
        CellStyle="{StaticResource gridcellStyle}"/>
 
     </telerik:RadGridView.Columns>
 
   </telerik:RadGridView>
 
 </telerik:RadBusyIndicator>
Dimitrina
Telerik team
 answered on 03 Sep 2013
1 answer
144 views
Dear Telerik Support Team!

I am so beginner with C# and WPF technologic. My managers liked the telerik's options what they could saw with your demos.
I have to use Oracle 11g database server, therefore I maked a sample OLAP database and sample cubes.
I have a hostname(192.168.81.112), a port(1521), and a SID(orcl), and a username, and password to identify that oracle database connection. I found some sample what you have done (RadPivotGrid-XmlaDataProvider-SimpleApp-SL) it looks like those maked to microsoft databases.
The cube name is SALES_CUBE and the used dimensions are: CHANNEL, TIME, GEOGRAPHY, PRODUCT.
Do you have any sample code how could i use any provider to oracle olap cube?

Thank you in anticipation,
Best regards,

Ed
Rosen Vladimirov
Telerik team
 answered on 03 Sep 2013
1 answer
86 views
Hi,

Could you please show how to create a dark windows8 touch theme?
Also how to use the colors of the theme in other parts of my app?

Thank you
Rosen Vladimirov
Telerik team
 answered on 03 Sep 2013
9 answers
323 views
Hi

RadTreeListView is taking time to display the records when the volume of records being added at very shot intervals are high
The same piece of code works absolutely find in RadGridView just replacing the RadTreeListView to RadGridView in xaml

To explain further, If I have 20k records in RadTreeListView and add 10 records at a time three times in a very quick succession (few milliseconds gap), the UI freezes for a few milliseconds and displays 30 records at one go where as the same piece of code works fine in RadGridView as I can see 10 records each coming in to the Grid.

Unfortunately I cannot post the sourcecode as it is bit complex but would like to know if I am missing anything? It could be just a property or something else or is it the behavior of RadTreeListView?

I have one level of hierarchy in RadTreeListView and it is the same behavior even if the hierarchy do not contain any data

The reason I am using RadTreeListView is basically it aligns the columns in the hierarchy with parent records which is missing in RadGridView

Any information is much appreciated.
Yordanka
Telerik team
 answered on 03 Sep 2013
5 answers
170 views
Hello,

I'm getting this error if i try to input "9999/12/31 24:00".
System.ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime.
Parameter name: value

This doesn't happen the first time. The first time, it just changes to 12:00 which is okay. On re-input, I get the above error. Somehow the control throws this error and I can't catch this even in the viewModel.
Rosen Vladimirov
Telerik team
 answered on 03 Sep 2013
1 answer
215 views
You have IsSnapToItemsEnabled and IsSnapToGridEnabled. Neither of these snaps to connectors (custom-positioned connectors). I believe snapping is pretty useless if you cannot snap in such way that connections are perpendicular lines.

E.g. This is what it looks like when snapping is enabled. No matter what, the line between the connectors will be non-perpendicular.

[------------------C------------------]
                        \
      [--------------C--------------]

Moving to the left snaps to a new grid line:

[------------------C------------------]
                       /
    [--------------C--------------]

What I want is this:

[------------------C------------------]
                       |
    [--------------C--------------]


Can you please add such a feature? You have to agree that it makes sense to have this. Thanks.
Pavel R. Pavlov
Telerik team
 answered on 03 Sep 2013
1 answer
257 views
I have custom classes and custom styles for RadDiagram, RadDiagramShape, RadDiagramConnection, RadDiagramConnector. Now I have run into a styling issue that requires pro help from you :)

I want my connectors to show their label when either of these two conditions is met:
1) The connector's shape (or any of its children) is hovered by the mouse.
2) Any connection, from any shape, is being dragged.

I started off adding a TextBlock to my connector style, but it seems I cannot properly toggle its visibility. If I set it to "Collapsed", it is never shown. Maybe this approach is all wrong, but still, here it is:

<Style TargetType="chart:MyChartConnector" x:Key="MyChartConnectorStyle" BasedOn="{StaticResource RadDiagramConnectorStyle}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <!-- Auto seems reasonable? -->
    <Setter Property="Width" Value="Auto" />
    <Setter Property="Height" Value="Auto" />
 
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="chart:MyChartConnector">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="MouseStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="MouseOver">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="DisplayElement"
                                            Storyboard.TargetProperty="Visibility">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ActiveStates">
                            <VisualState x:Name="Inactive" />
                            <VisualState x:Name="Active">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0"
                                            Storyboard.TargetName="DisplayElement"
                                            Storyboard.TargetProperty="Visibility">
                                        <DiscreteObjectKeyFrame KeyTime="0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Grid>
                        <Ellipse x:Name="OverElement"
                                 Width="20"
                                 Height="20"
                                 Fill="{TemplateBinding Background}"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Stroke="{TemplateBinding BorderBrush}" />
                        <Ellipse x:Name="DisplayElement"
                                 Width="20"
                                 Height="20"
                                 Fill="#40000000"
                                 StrokeThickness="{TemplateBinding BorderThickness}"
                                 Stroke="{TemplateBinding BorderBrush}" />
 
                        <!-- This does not work as intented :( -->
                        <TextBlock Text="{TemplateBinding DisplayName}" Visibility="Collapsed">
                            <TextBlock.Style>
                                <Style TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type chart:MyChartShape}}, Path=IsMouseOver}" Value="True" >
                                            <Setter Property="Visibility" Value="Visible" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Hristo
Telerik team
 answered on 03 Sep 2013
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
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?