Telerik Forums
UI for WPF Forum
5 answers
219 views
Hi,

can we get the the Themes for all controls to the entire application (App Resource) as part of WPF Control bundle??

Thanks,
Suman
Vanya Pavlova
Telerik team
 answered on 02 Dec 2010
1 answer
202 views

I have just started working with Telerik controls having moved from Infragistics controls.

I have created a 3D pie chart in code-behind whose data is gathered from a database.

The legend items for the chart are also gathered from the database (both the title of each item and its colour is stored in the database as these colours are customisable by the user for each category).

I have managed to set the legend item colours correctly but now I need to set the colours of each 'slice' of the pie chart to match the legend.

I have followed the example on setting custom item styles at http://www.telerik.com/help/wpf/radchart-styling-and-appearance-custom-item-style.html but when I set a breakpoint on the BuildCustomItemStyles method it is only ever trying to style the legend items.

Here is my cod behind (including the BuildCustomItemStyles code).

/// <summary>
/// Interaction logic for AbsenceByReasonChart.xaml
/// </summary>
public partial class AbsenceByReasonChart : UserControl, IWpfChart
{
    private List<OptionPropertiesData> optionPropertiesSet;
    /// <summary>
    ///     Default constructor.
    /// </summary>
    public AbsenceByReasonChart()
    {
        InitializeComponent();
        radChart1.
        Loaded += new RoutedEventHandler(AbsenceByReasonChart_Loaded);
    }
    private void AbsenceByReasonChart_Loaded(object sender, RoutedEventArgs e)
    {
        WpfZoomUtils.ZoomChartArea(radChart1.DefaultView.ChartArea, Constants.WpfChartZoomFactor);
    }   
      
    private Style BuildCustomItemStyle(Control item, Style style, DataPoint point, DataSeries dataSeries) 
    { 
        if ((item as BaseChartItem3D<Pie3D>) == null) return style; 
        Style newStyle = new Style(); 
        newStyle.BasedOn = style; 
        newStyle.TargetType = typeof(Shape); 
        // this code gets the brush colour
        Brush brush = new SolidColorBrush(getOptionColour(...));
  
        newStyle.Setters.Add(new Setter(Shape.FillProperty, brush)); 
  
        return newStyle; 
    } 
    public void SetChartTitle(DateTime startDate, DateTime endDate)
    {
        if (startDate == DateTime.MinValue || startDate == null) return;
        radChart1.DefaultView.ChartTitle.Content = string.Format("Absence by Reason {0} to {1}", startDate.ToShortDateString(), endDate.ToShortDateString());
        radChart1.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center;
    }
    public void PopulateChart(DataTable data, DateTime startDate, DateTime endDate, List<OptionPropertiesData> optionPropertiesList)
    {
        if (data == null || data.Rows.Count == 0 || optionPropertiesList == null || optionPropertiesList.Count == 0) return;
        optionPropertiesSet = optionPropertiesList;
        if (radChart1.DefaultView.ChartArea.DataSeries != null && radChart1.DefaultView.ChartArea.DataSeries.Count > 0)
        {
            // remove existing data series
            radChart1.DefaultView.ChartArea.DataSeries.Clear();
        }
        // define series data type
        DataSeries series = new DataSeries()
        {
            Definition = new Pie3DSeriesDefinition(),
            LegendLabel = "Attendance Type"
        };
        // turn on item tooltips and set the item format of the tooltip for each series item
        ISeries3DDefinition chartDefintion = series.Definition as Pie3DSeriesDefinition;
        if (chartDefintion != null)
        {
            chartDefintion.ShowItemToolTips = true;
            chartDefintion.ItemToolTipFormat = "#LEGENDLABEL: #Y Employees";
            chartDefintion.ItemLabelFormat = "#%{p0}";
        }
        // for the absence by reason chart, the legend colours must match the colours defined for each atendance type
        // in the attendance maintenance section
          
        // first, turn OFF the automatic generation of the legend for the chart
        radChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = false;
        // whilst the chart is being populated, set the legend item appropriately
        foreach (DataRow r in data.Rows)
        {
            if (r == null || r.ItemArray == null || r.ItemArray.Length == 0) continue;
            // the item array of each data row has the following information:
            // first item is the absence reason
            // second item is the number of employees off due to this reason
            // third item is the id of the data option for the absence reason
            if (r.ItemArray[1] is int && r.ItemArray[0] is string && r.ItemArray[2] is long)
            {
                // ignore categories that have no value or rows where the absence reason data option id cannot be found
                if (Convert.ToInt32(r.ItemArray[1]) <= 0 || Convert.ToInt64(r.ItemArray[2]) <= 0) continue;
                // set the data for this category
                series.Add(new DataPoint 
                {                                        
                    XValue = Convert.ToInt64(r.ItemArray[2]),
                    YValue = Convert.ToInt32(r.ItemArray[1]), 
                });
                // now define its legend item
                ChartLegendItem legendItem = new ChartLegendItem()
                {
                    Background = new SolidColorBrush(getOptionColour(Convert.ToInt64(r.ItemArray[2]), optionPropertiesList)),
                    Label = Convert.ToString(r.ItemArray[0])
                };
                radChart1.DefaultView.ChartLegend.Items.Add(legendItem);
            }
        }
        SetChartTitle(startDate, endDate);
        // finally, assign the chart the defined data series
        radChart1.DefaultView.ChartArea.DataSeries.Add(series);
    }
    private System.Windows.Media.Color getOptionColour(long optionID, List<OptionPropertiesData> optionPropertiesList)
    {
        // find the option properties object for the option with the passed in option id
        // and return its associated colour
        OptionPropertiesData optionProperty = optionPropertiesList.Find(delegate(OptionPropertiesData opData) { return opData.getDataOptionID() == optionID; });
        if (optionProperty != null)
        {
            System.Drawing.Color winFormColour = System.Drawing.Color.FromArgb(optionProperty.getPlannerColour());
            if (winFormColour != null)
            {
                return new System.Windows.Media.Color()
                {
                    A = winFormColour.A,
                    R = winFormColour.R,
                    G = winFormColour.G,
                    B = winFormColour.G
                };
            }
        }
        return new Color();
    }
    public RadChart GetChartInstance()
    {
        return radChart1;
    }
Vladimir Milev
Telerik team
 answered on 02 Dec 2010
2 answers
184 views
Hi,

How do i have a custom style template for the OutlookBar?

Thanx
Maqsood
Pinaki Basu
Top achievements
Rank 1
 answered on 02 Dec 2010
7 answers
547 views
I am trying to show/hide series in a line chart. I am trying to use the Visibility property of the class LineSeriesDefinition . However it is not working and the concerned series remains visible. Please help.

The code is as follows:

 

SeriesMapping Mapping = new SeriesMapping();

 

Mapping .CollectionIndex = 0;

 

 

 

 

LineSeriesDefinition lineDefinition = new LineSeriesDefinition();

 

lineDefinition.Visibility =

 

SeriesVisibility.Collapsed; // I tried with 'Hidden' as well

 

lineDefinition.ShowItemLabels =

 

false;

 

lineDefinition.ShowPointMarks =

 

false;

 

lineDefinition.Appearance.Stroke =

 

Brushes.LightSalmon;

 

lineDefinition.Appearance.StrokeThickness = 1.0;

Mapping .SeriesDefinition = lineDefinition;

Mapping .ItemMappings.Add(

 

new ItemMapping("X Label", DataPointMember.XValue));

 

 

 

ItemMapping yItemMapping = new ItemMapping("Y Label", DataPointMember.YValue);

 

yItemMapping.SamplingFunction =

 

ChartSamplingFunction.Average;

 

Mapping.ItemMappings.Add(yItemMapping);

 

LineChart.SeriesMappings.Add(Mapping );



Yavor
Telerik team
 answered on 02 Dec 2010
2 answers
261 views
Hi,

Is it possible to bind a SortDescriptiorCollection directly to the xaml?

i.e
<telerikGrid:RadGridView.SortDescriptors ItemSource="{Binding SortDescriptors}" />
 
NOTE: Sorry I meant his to be in the Silverlight section for GridVIew
Sara :)
<telerikGrid:RadGridView.SortDescriptors ItemSource="{Binding SortDescriptors}">
<telerikGrid:RadGridView.SortDescriptors ItemSource="{Binding SortDescriptors}">
DeveloperDame
Top achievements
Rank 1
 answered on 01 Dec 2010
3 answers
741 views
I am handling the RowEditEnded event of my RadGridView to save the changes to the database through a service.  But if I get an error from the middle tier, I want to roll back those changes to the row.

At the time RowEditEnded is raised, it is too late to call CancelEdit(), so I thought that using the OldValues property of  GridViewRowEditEndedEventArgs would be the best way to go, and apply them to each cell in the row. The problem is that OldValues is a dictionary and GridViewCellBase can only be indexed by position.  I could find each cell binding and find the item in OldValues that matches it, but it seems to me that there should be a better way.

Is there an easy way to do this?
Roger
Top achievements
Rank 1
 answered on 01 Dec 2010
1 answer
203 views
Hi ,

I am Ramesh , I am using Telerik controls and Grid in our application . we are using Telerik 2010 Q3 release dll

My Requirement is  

Typing "010110" should translate to 01/01/2010 automatically 

Let me know if there is any property available in Date picker control which satisfies this functionality


Thanks in Advance

Regards
Ramesh
George
Telerik team
 answered on 01 Dec 2010
1 answer
178 views
1. How can I create a Spline chart like in WPF Chart example with custom Values(it will help me to understand the structure)?

I tried 
List<double[]> itemsSource = new List<double[]>();
itemsSource.Add(SeriesExtensions.GetUserData(12, 0));
itemsSource.Add(SeriesExtensions.GetUserData(12, 1));

but "SeriesExtensions" gives me an error.

2. Is it possible to Align the Y-Axis label?..by default it's center align.
Thanks
Evgenia
Telerik team
 answered on 01 Dec 2010
2 answers
130 views
Hi there,

in relation to your online demo I have built a grid with syncronisation between a TextBox an the GridCells. It works fine and I decided to add theese grid to a greater application.
In this application I can't get it to work.  I just get an error the ressource "SyncToBoxTemplate" will not be found.
What does I've done wrong? I have copied the code 1:1

<Window x:Class="ICConfPrototyp.Entscheidungstabelle"
        Title="MainWindow" Height="396" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Window.Resources>
        <DataTemplate x:Key="SyncToBoxTemplate">
            <TextBox Loaded="TextBox_Loaded" />
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <TextBox Grid.Row="0"  Height="25" VerticalAlignment="Center" Name="txtValue" IsEnabled="True" />
        <telerik:RadGridView telerik:StyleManager.Theme="Windows7" HorizontalAlignment="Stretch"  Name="rgvEntscheidungstabelle" VerticalAlignment="Stretch" ShowGroupPanel="False" CanUserReorderColumns="False" CanUserSortColumns="False"  IsManipulationEnabled="True" Loaded="rgvEntscheidungstabelle_Loaded" RowLoaded="rgvEntscheidungstabelle_RowLoaded" IsFilteringAllowed="False" Grid.Row="1" SelectionUnit="Cell" SelectionMode="Extended" SelectedCellsChanged="grdView_SelectedCellsChanged" PreviewMouseLeftButtonDown="grdView_PreviewMouseLeftButtonDown" MouseLeftButtonDown="grdView_MouseLeftButtonDown" AutoGenerateColumns="False" GroupHeaderTemplate="{StaticResource SyncToBoxTemplate}">         
            <telerik:RadGridView.LayoutTransform>
                <ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoomSlider}"
                            ScaleY="{Binding Path=Value, ElementName=zoomSlider}"/>
            </telerik:RadGridView.LayoutTransform>
        </telerik:RadGridView>
        <TextBox Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="256,4,0,0" Name="txtProzent" VerticalAlignment="Top" Width="34" Text="100" HorizontalContentAlignment="Center" TextChanged="txtProzent_TextChanged" />
        <Label Content="%" Grid.Row="2" Height="28" HorizontalAlignment="Left" Margin="287,2,0,0" Name="label1" VerticalAlignment="Top" />
        <telerik:RadSlider Name="zoomSlider" Minimum="0.001" Maximum="5" Value="1" Grid.Row="2" TickFrequency=".5" TickPlacement="Both" Margin="308,0,0,0" ValueChanged="zoomSlider_ValueChanged" HandlesVisibility="Visible">
            <telerik:StyleManager.Theme>
                <telerik:Windows7Theme />
            </telerik:StyleManager.Theme>
        </telerik:RadSlider>
        <telerik:RadContextMenu.ContextMenu>
 
            <telerik:RadContextMenu Opened="RadContextMenu_Opened"
                                    ItemClick="RadContextMenu_ItemClick">
 
                <telerik:RadContextMenu.Items>
                    <!--menu items -->
 
                    <telerik:RadMenuItem Header="Zelle kopieren"
                                         Name="contextmenue_copy_cell">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/table_row.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem Header="kopierter Zelleninhalt einfügen"
                                         Name="contextmenue_insert_clipboard_cell">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/table_cell.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem IsSeparator="True" />
 
                    <telerik:RadMenuItem Header="Zeile anfügen"
                                         Name="contextmenue_append_line">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/table_row.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem Header="Zeile einfügen"
                                         Name="contextmenue_insert_line">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/table_column_add.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem Header="Zeile kopieren"
                                         Name="contextmenue_copy_line">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/copy.ico"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem Header="Zelle Editieren"
                                         Name="contextmenue_edit_cell">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/EditDocument.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem Header="Zeile löschen"
                                         Name="contextmenue_delete_line">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/delete.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem IsSeparator="True" />
 
                    <telerik:RadMenuItem Header="Spalte einfügen"
                                         Name="contextmenue_insert_column">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/table_column_add.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <telerik:RadMenuItem Header="Spalte löschen"
                                         Name="contextmenue_delete_column">
                        <telerik:RadMenuItem.Icon>
                            <Image Source="/ICConfPrototyp;component/Images/table_column_delete.png"
                                   Stretch="UniformToFill" />
                        </telerik:RadMenuItem.Icon>
                    </telerik:RadMenuItem>
 
                    <!--items -->
                </telerik:RadContextMenu.Items>
 
            </telerik:RadContextMenu>
 
        </telerik:RadContextMenu.ContextMenu>
    </Grid>
</Window>

I don't have any Ideas :(

Greetings
Andi
Andi
Top achievements
Rank 2
 answered on 01 Dec 2010
2 answers
142 views

 

Hello,
I am trying to implement similar functionality with the dependency arrow  in Gantt charts.
Anyone know the best way to do it?
George
Telerik team
 answered on 01 Dec 2010
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
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?