Telerik Forums
UI for WPF Forum
1 answer
142 views
Hello
I am a newbie in WPF RadChart. Currently I am doing a project where data will be displayed in stacked bar chart. I bound SeriesMappingCollection ViewModel property to SeriesMapping xaml property but it seems works only once (when viewmodel is instantiated)
I am unable to force chart to redraw itself when SeriesMappingCollection is feed with new portion of data.

XAML:
<telerik:RadChart
                        x:Name="DefectChart"
                        Grid.Row="1"
                        SeriesMappings="{Binding DiagramMappings}">
</telerik:RadChart>

ViewModel:
SeriesMappingCollection _mappings;
public SeriesMappingCollection DiagramMappings
{
    get
    {
        if (_mappings == null)
        {
            _mappings = new SeriesMappingCollection();
            var temp = new SeriesMappingCollection();
 
            var sm = new SeriesMapping();
            sm.SeriesDefinition = new StackedBarSeriesDefinition();
            sm.ItemMappings.Add(new ItemMapping("Category", DataPointMember.XCategory));
            sm.ItemMappings.Add(new ItemMapping("Data", DataPointMember.YValue));
            sm.ItemsSource = new List<ChartData>()
    {
        new ChartData("C1", 1),
        new ChartData("C2", 5),
        new ChartData("C3", 7)
    };
 
            temp.Add(sm);
 
            var sm2 = new SeriesMapping();
            sm2.SeriesDefinition = new StackedBarSeriesDefinition();
            sm2.ItemMappings.Add(new ItemMapping("Category", DataPointMember.XCategory));
            sm2.ItemMappings.Add(new ItemMapping("Data", DataPointMember.YValue));
            sm2.ItemsSource = new List<ChartData>()
    {
        new ChartData("C1", 10),
        new ChartData("C2", 7),
        new ChartData("C3", 18)
    };
            temp.Add(sm2);
            this._mappings = temp;
        }
        return _mappings;
    }
    set
    {
        _mappings = value;
        NotifyOfPropertyChange(() => DiagramMappings);
    }
}

in getter I am using the mocked data, and this is drawn on chart, but after update of the SeriesMappingCollection next time chart doesn't reflect any changes.


Mocked chart data (btw taken from on of your examples)

public class ChartData
    {
        public ChartData(string c, double d)
        {
            this.Category = c;
            this.Data = d;
        }
 
        public string Category { get; set; }
        public double Data { get; set; }
    }


Thanks in advance for help.
Regards
Petar Marchev
Telerik team
 answered on 04 Jun 2013
1 answer
248 views
Hello, I am trying to get byte code of QR but I faced issue.
It's standard sample from telerik

var qRCode = new RadBarcodeQR();
qRCode.ErrorCorrectionLevel = QRClassLibrary.Modes.ErrorCorrectionLevel.H;
qRCode.Mode = QRClassLibrary.Modes.CodeMode.Byte;
qRCode.Version = 2;
 
qRCode.Text = "TestText";
 
const string extension = "png";
var dialog = new SaveFileDialog()
{
    DefaultExt = extension,
    FileName = "QRBarCode",
    Filter = "Png (*.png)|*.png"
};
 
if (dialog.ShowDialog() == true)
{
    using (var stream = dialog.OpenFile())
    {
        ExportExtensions.ExportToImage(qRCode, stream, new PngBitmapEncoder());
    }
}

But I have got the next Exception 

The parameter value must be greater than zero.
Parameter name: pixelWidth

   at System.Windows.Media.Imaging.RenderTargetBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat)
   at Telerik.Windows.Media.Imaging.ExportHelper.GetBitmapSource(FrameworkElement element, Double dpiX, Double dpiY) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\ExportHelper.cs:line 97
   at Telerik.Windows.Media.Imaging.ExportHelper.GetElementImage(FrameworkElement element) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\ExportHelper.cs:line 70
   at Telerik.Windows.Media.Imaging.ImageExporter.Export(FrameworkElement element, Stream stream, BitmapEncoder encoder) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\ImageExporter.cs:line 12
   at Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(FrameworkElement element, Stream stream, BitmapEncoder encoder) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\ExportExtensions\ExportExtensions.cs:line 100
   at WpfApplication1.MainWindow.ButtonBase_OnClick(Object sender, RoutedEventArgs e) in c:\Users\smile\Documents\Visual Studio 2012\Projects\WpfApplication1\WpfApplication1\MainWindow.xaml.cs:line 352
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at WpfApplication1.App.Main() in c:\Users\smile\Documents\Visual Studio 2012\Projects\WpfApplication1\WpfApplication1\obj\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()



What am I doing wrong?
I need to get the byte[] of image source (QR, BaCode and so on), could you give me sample of code what I need to do, please? (NOT LINK, I want to see a working example)
Thank You
Yavor
Telerik team
 answered on 04 Jun 2013
1 answer
57 views
Ok, I consider myself an accomplished WPF designer, but I cannot seem to get rid of the default style in the column headers for the RadGridView.  Any help would be appreciated.  Please just tell me which template to override with my own styles.  This shouldn't be so difficult.
Steve Schmidt
Top achievements
Rank 1
 answered on 03 Jun 2013
1 answer
170 views
Hi , is there a way to export asynchronous a very big amount of data without freezing the UI?
I've to export up to 1'000'000+ rows and the program is freezed for a long time while the grid is exporting.

Thanks,
Massimo
Ivan Ivanov
Telerik team
 answered on 03 Jun 2013
1 answer
165 views
Hi,

I have RadListBoxes and user can drag and drop stuff between them but how can I check what the drop target is when OnDragCompleted is fired?

The problem is that I want to remove data from database if user drags stuff outside the listbox but not remove data from database if user drags stuff to other listbox. I can't seem to find out which drag and drop has been done at the moment...

Now I can get the source of drag operation from sender but how can I get the target for the drop?

Drag and drop target

Br,

Kalle
Yoan
Telerik team
 answered on 03 Jun 2013
9 answers
365 views
Hi,

I have a control template that needs to be applied to all of my combo boxes in my project, including those in the property grid I have. I am using the Editable and and noneditable template to get the style that I am looking for. My property grid uses items such as textboxes, checkboxes, datetimepickers, and comboboxes. Is there a way to apply the same control template to all combo boxes that appear in my propertygrid?

Thanks
Maya
Telerik team
 answered on 03 Jun 2013
1 answer
339 views
I have the following CellTemplate for a few columns in my RadGridView:

<DataTemplate x:Key="TextCell" DataType="telerik:GridViewCell">
        <TextBlock Text="{Binding Value,
                                  RelativeSource={RelativeSource FindAncestor,
                                                                 AncestorType={x:Type telerik:GridViewCell}}}"
                   TextAlignment="{Binding TextAlignment,
                                           RelativeSource={RelativeSource TemplatedParent}}"
                   TextTrimming="CharacterEllipsis"
                   TextWrapping="NoWrap" />
    </DataTemplate>

This is being applied correctly, but I need to access properties such as TextAlignment and DataFormatString that are set on the GridDataViewColumn for that cell.  As you can see I've tried to access via the TemplatedParent, but to no avail.  How can I access these properties, so I can use them within my template?

Thanks.
Maya
Telerik team
 answered on 03 Jun 2013
2 answers
110 views
Hello!

I have the problem with binding to the CategoryBinding property.
I have this code:

                <telerik1:BarSeries CategoryBinding="HourName"
                                    ItemsSource="{Binding ChartData}"
                                    ValueBinding="Value"
                                    />

Chart Data has the values for X and Y axises. I need to show datas which represent each day of week per hour, and in one case it must be data per week

so i need to present sunday, monday ..... and whole week.

in my ChartData i put datas apropriately to my needs :

for day of week :
1 2 3 4 5 ... 24  --- CategoricalBinding
4 5 6 7 3 ... 221 --- Some Garbage datas

and for whole week i need have something like this :
1 2 3 4 ... 24 1 2 3 ... 24 1 2 3 ... 24 ..... 24 -CategoricalBinding for whole week this means 168 categories ( 7*24 hours)
2 1 1 1 ................... Some Garbage datas


But chart don't want to display whole week like 168 categories ( 7*24 hours), it just display 24 categories with united data.

What should i do? Could you help me please?

Thanks and Regards!
srikanth
Top achievements
Rank 1
 answered on 03 Jun 2013
1 answer
175 views
Hi,

how do i add a radwindow to my wpf Project? I can't find it if i try to add e new element to my Project?

Thanks
best Regards
Rene
Kalin
Telerik team
 answered on 03 Jun 2013
1 answer
84 views
I have a WPF data Grid in which I have a Column called Qty having data sequnce:
2,1,4,5,3

When I click on Filter the popup also displays the data as 2,1,4,5,3. But how can it be sorted as 1,2,3,4,5 


I thought of  writing  SortMemberPath inside  <telerik:GridViewDataColumn but don't want to do that as I am not using GridViewDataColumn.

Attached the current scenario.
Yoan
Telerik team
 answered on 03 Jun 2013
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?