Telerik Forums
UI for WPF Forum
1 answer
265 views
I'm trying to write an app where each part of the config is held in a usercontrol.  In moving this to WPF from winforms I thought it would look good to put the config tabbed in a ribbon at the top.

I tried using the ribbonbar but ran into a problem when a tab was selected that contained a usercontrol  I've now got the RibbonView and tried the same thing and run into the same problem.

My code is:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:WpfApplication1="clr-namespace:WpfApplication1">
    <Grid>
        <telerik:RadRibbonView Name="radRibbonView1" >
            <telerik:RadRibbonTab>
                <WpfApplication1:UserControl1/
            </telerik:RadRibbonTab>
        </telerik:RadRibbonView>
    </Grid>
</Window>


Where UserControl1 is an empty user control.

When I try to run this, I get the following error:

Specified element is already the logical child of another element. Disconnect it first.

The trace is:

   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)
   at System.Windows.Controls.HeaderedContentControl.OnHeaderChanged(Object oldHeader, Object newHeader)
   at System.Windows.Controls.HeaderedContentControl.OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.StyleHelper.ApplyTemplatedParentValue(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, DependencyProperty dp, FrameworkElementFactory templateRoot)
   at System.Windows.StyleHelper.InvalidatePropertiesOnTemplateNode(DependencyObject container, FrameworkObject child, Int32 childIndex, FrugalStructList`1& childRecordFromChildIndex, Boolean isDetach, FrameworkElementFactory templateRoot)
   at System.Windows.FrameworkTemplate.InvalidatePropertiesOnTemplate(DependencyObject container, Object currentObject)
   at System.Windows.FrameworkTemplate.HandleBeforeProperties(Object createdObject, DependencyObject& rootObject, DependencyObject container, FrameworkElement feContainer, INameScope nameScope)
   at System.Windows.FrameworkTemplate.<>c__DisplayClass6.<LoadOptimizedTemplateContent>b__3(Object sender, XamlObjectEventArgs args)
   at System.Xaml.XamlObjectWriter.OnBeforeProperties(Object value)
   at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
   at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
Viktor Tsvetkov
Telerik team
 answered on 08 Aug 2011
2 answers
142 views
The data renders just fine but the Click event does not fire...

XAML below

<telerikChart:RadChart x:Name="radChartCompanyRevenue" Width="500" Height="350" IsEnabled="True">
    <telerikCharting:ChartDefaultView>
        <telerikCharting:ChartDefaultView.ChartLegend>
            <telerikCharting:ChartLegend Visibility="Collapsed" />
        </telerikCharting:ChartDefaultView.ChartLegend>
        <telerikCharting:ChartDefaultView.ChartArea>
            <telerikCharting:ChartArea ItemClick="ChartArea_ItemClick" />
        </telerikCharting:ChartDefaultView.ChartArea>
    </telerikCharting:ChartDefaultView>
    <telerikChart:RadChart.SeriesMappings>
        <telerikCharting:SeriesMapping>
            <telerikCharting:SeriesMapping.SeriesDefinition>
                <telerikCharting:PieSeriesDefinition>
                </telerikCharting:PieSeriesDefinition>
            </telerikCharting:SeriesMapping.SeriesDefinition>
            <telerikCharting:SeriesMapping.ItemMappings>
                <telerikCharting:ItemMapping DataPointMember="XCategory" FieldName="Month"/>
                <telerikCharting:ItemMapping DataPointMember="YValue" FieldName="Revenue"></telerikCharting:ItemMapping>
            </telerikCharting:SeriesMapping.ItemMappings>
        </telerikCharting:SeriesMapping>
    </telerikChart:RadChart.SeriesMappings>
</telerikChart:RadChart>

C# code below

// constructor
public DrillDown_Report()
{
    InitializeComponent();           
    BindCompanyRevenue();
}
private void ChartArea_ItemClick(object sender, Telerik.Windows.Controls.Charting.ChartItemClickEventArgs e)
{
    CompanyRevenue_Event cr = e.DataPoint.DataItem as CompanyRevenue_Event;
    MessageBox.Show(cr.Month + " " + cr.Revenue.ToString());
}
#region Company Revenue
private void BindCompanyRevenue()
{
    radChartCompanyRevenue.ItemsSource = this.GetCompanyRevenue();
    radChartCompanyRevenue.DefaultView.ChartTitle.Content = "Company Revenue";
    radChartCompanyRevenue.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
    radChartCompanyRevenue.DefaultView.ChartArea.ItemClick += new EventHandler<Telerik.Windows.Controls.Charting.ChartItemClickEventArgs>(ChartArea_ItemClick);
}
private List<CompanyRevenue_Event> GetCompanyRevenue()
{
    List<CompanyRevenue_Event> companyRevenue = new List<CompanyRevenue_Event>();
    companyRevenue.Add(new CompanyRevenue_Event(2011, "Jan", 189213.58));
    companyRevenue.Add(new CompanyRevenue_Event(2011, "Feb", 179213.58));
    companyRevenue.Add(new CompanyRevenue_Event(2011, "Mar", 180213.58));
    companyRevenue.Add(new CompanyRevenue_Event(2011, "Apr", 184213.58));
    return companyRevenue;
}
#endregion

Marcelo
Top achievements
Rank 1
 answered on 08 Aug 2011
2 answers
369 views
Hi,

I using a MVVM environment and try to achieve an auto size of all columns depending on a user preselected mode.
Therefore I've bound the RadGridView.ColumnWidth to a Property in the ViewModel. As I change the value of the property the values of the grid is also changing but the existing Columns are not resized. To force the resize if have iterate to each Column an change the Width.
But is not the best thing to do in an MVVM concept. Is there any better solution for that?

Regards
Thomas
Thomas
Top achievements
Rank 1
 answered on 08 Aug 2011
4 answers
166 views
I used the following in a console app to create and save Chart to png.
It works for LineSeries but the BarSeries is missing.
Please help.



using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Threading;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Charting;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Processor processor = new Processor();
            processor.Process();
        }
    }

    public class Processor
    {
        private SaveChartProcessor _ruleProcessor = new SaveChartProcessor();
        public void Process()
        {
            var processRuleThread = new Thread(workerThreadProcessRule);
            processRuleThread.Start();
        }

        private void workerThreadProcessRule()
        {
            _ruleProcessor.SaveImage();
        }
    }


    public class SaveChartProcessor
    {
        public void SaveImage()
        {
            var newThread = new Thread(processChartImageWorker);
            newThread.SetApartmentState(ApartmentState.STA);
            newThread.Start();
        }

        public void processChartImageWorker()
        {
            var chart = new RadChart();
            chart.BeginInit();

            chart.Width = 640;
            chart.Height = 480;
            chart.DefaultView.ChartArea.EnableAnimations = false;

            SeriesMapping sm1 = new SeriesMapping();
            //sm1.SeriesDefinition = new LineSeriesDefinition();   //<-LineSeries works
            sm1.SeriesDefinition = new BarSeriesDefinition();      //<-BarSeries doesn't work
            sm1.LegendLabel = "Line Series 1";
            sm1.CollectionIndex = 0;
            ItemMapping im1 = new ItemMapping();
            im1.DataPointMember = DataPointMember.YValue;
            sm1.ItemMappings.Add(im1);
            SeriesMapping sm2 = new SeriesMapping();
            //sm2.SeriesDefinition = new BarSeriesDefinition();
            sm2.SeriesDefinition = new LineSeriesDefinition();
            sm2.LegendLabel = "Line Series 2";
            sm2.CollectionIndex = 1;
            ItemMapping im2 = new ItemMapping();
            im2.DataPointMember = DataPointMember.YValue;
            sm2.ItemMappings.Add(im2);

            // Force chart to measure itseft so it provides the actual width and height to export
            chart.Measure(new System.Windows.Size(chart.Width, chart.Height));
            chart.Arrange(new System.Windows.Rect(chart.DesiredSize));

            chart.SeriesMappings.Add(sm1);
            chart.SeriesMappings.Add(sm2);

            chart.EndInit();

            var itemsSource = new List<double>[] { new List<double> { 9, 2, 3, 4 }, new List<double> { 5, 7, 3, 4 } };
            chart.ItemsSource = itemsSource;

            string path = "d:\\newpic.png";

            chart.Dispatcher.Invoke(
                    new Action(() =>
                    {
                        chart.Save(path);
                    }),
                    DispatcherPriority.Normal);
        }
    }
}
Sia
Telerik team
 answered on 08 Aug 2011
1 answer
121 views
Hi Telerik,

we are unable select an item through code. we used the item.IsSelected=true. though it highlited in different color from the one which is shown when we clicked manually. Please could you help us resolving this.
Petar Mladenov
Telerik team
 answered on 08 Aug 2011
1 answer
76 views
How do i do this?

the scenario is that i have this certain student collection, each student can choose all or some of his enrolled subjects from the multiselect control.

how would you guys do this with a RadGridview Column?

Using mvvm, I tried binding the gridviewcomboboxcolumn with a Keyvaluepair of id  and a checkbox collection, but when i tried to show it, it doesn't display the checkbox control in the combo box.
Vanya Pavlova
Telerik team
 answered on 08 Aug 2011
5 answers
228 views
Hi

Just wondering if there is a CRUD example with ef4.0

cheers

Jason
Rossen Hristov
Telerik team
 answered on 08 Aug 2011
1 answer
118 views
Hi,

I found this post in the Telerik blogs that provides a simple way to reorder rows by dragging and dropping.  The blogger provided source code to use.  However, the WPF Telerik dll files are from 2010 and therefore I upgraded them to 2011 Q2.  After I had upgraded the dll's, the size of the rows that were being dragged by the mouse increased and expanded to the whole width screen.  In other words, they looked like they were being magnified or zoomed in.  I didn't change any of the source code.  I just upgraded the Telerik dlls.  Is there anyway to make the dragged rows appear normal in size?

Here is the link to the blog:
 http://blogs.telerik.com/silverlightteam/posts/10-05-20/enable-radgridview-rsquo-s-rows-reorder-functionality-using-behaviors.aspx

I don't see how to attach the entire solution, but if you download the WPF solution from the link and then upgrade the WPF Telerik dlls to 2011 Q2, you should hopefully be able to recreate the drag & drop size issue.

Thanks,
Joe
Vanya Pavlova
Telerik team
 answered on 08 Aug 2011
0 answers
64 views
Moving this to Silverlight Forum
Roland
Top achievements
Rank 1
 asked on 08 Aug 2011
4 answers
175 views

Hi,

I want to collapse the hierarchy expand button (its border container to be accurate) so there will be no white space at the first column content when there is no hierarchy.

I saw that there is a property in the radTreeListView called HasHierarchy, but I cannot change its value (the set is not accessible).

I’ve managed to this in code:

            var gridHierarchyBorder = treeListView.FindChildByName("PART_HierarchyIndent") as Border;

            if (gridHierarchyBorder == null)

                return;

            gridHierarchyBorder.Visibility = Visibility.Collapsed;

But I guess there is a more efficient and elegant way to achieve this. Is there?

Rotem
Top achievements
Rank 1
 answered on 07 Aug 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?