WPF: add chart control inside Combobox

8 posts, 0 answers
  1. Gshhar
    Gshhar avatar
    11 posts
    Member since:
    Mar 2014

    Posted 17 Mar Link to this post

    So i have this model:

    public class MachineNetworkAdapter
    {
      public string Name { get; set; }
      public string IpAddress { get; set; }
      public static List<MachineNetworkAdapter> MachineAdapters;
    }

     

    So each mechine adapter have this members.
    So i have this Combobox that show all my Machine Adapters:

    <ComboBox
        Name="cbAdapterss"
        ItemsSource="{Binding MachineAdapters}"
        SelectionChanged="cbInterfaces_SelectionChanged"/>

     

    So in this case i can see all my machine adapters with this properties.
    Now i want to see also my adapters Rate in MBit/sec so i added this members:

    public Series { get; set; }
      public double Rate { get; set; }

     

    the member Rate is MBit/sec and the value is changing every 1 sec. the series is for the chart in order to put into the values.
    So i added template with chartand now this is my Combobox:

    <ComboBox
        Name="cbAdapters"
        ItemsSource="{Binding MachineAdapters}"
        SelectionChanged="cbInterfaces_SelectionChanged">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <telerik:RadCartesianChart
                    x:Name="chartTemplate"/>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

     

    So now all i can see in my Combobox is an empty chart without the other properties. So my question is how can i populate my chart and also see the other properties (Name, IPAddress).

  2. Dinko
    Admin
    Dinko avatar
    415 posts

    Posted 21 Mar Link to this post

    Hi Gshhar,

    Thank you for your interest in RadChartView.

    The chart is not populated because you haven't specified the axis which you are going to use and the series. You can take a look at the following resources which could help you to implement your approach.

    Hope this information is helpful. Please, let us know if further questions arise. 

    In addition, you set the Product tag of this thread to our old RadChart component. From the attached code snippet we can see that you are using the new chart (RadChartView) so we are changing the Product tag of this thread to RadChartView for WPF.

    Regards,
    Dinko
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Gshhar
    Gshhar avatar
    11 posts
    Member since:
    Mar 2014

    Posted 21 Mar Link to this post

    I need to specify the axis and the series although if i am using and create the series in code behind ?
  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1404 posts

    Posted 24 Mar Link to this post

    Hello Gshhar,

    I prepared a small example that demonstrates how you can use the chart in the described scenario. Please give it a try and let me know if it helps. I would also recommend you to check the resource provided by Dinko. You can check Getting Started that demonstrates how to set up the chart.

    About creating the series in code behind, you can do that. However, in your case this won't be very straight forward because you have the chart defined in a DataTemplate. This means that you cannot access it via code behind. In this case you could think of another approach setting the chart's properties in code. Or just define it in XAML.

    Regards,
    Martin
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Gshhar
    Gshhar avatar
    11 posts
    Member since:
    Mar 2014

    Posted 28 Mar in reply to Martin Ivanov Link to this post

    How can i open this ? it missing the .sln file.
  6. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1404 posts

    Posted 28 Mar Link to this post

    Hello,

    You can open the WpfApplication1.csproj file with Visual Studio.

    Regards,
    Martin
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  7. Gshhar
    Gshhar avatar
    11 posts
    Member since:
    Mar 2014

    Posted 1 day ago in reply to Martin Ivanov Link to this post

    Ok i can see the chart inside the Combo-Box but the Name and Ip Address is missing.
  8. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1404 posts

    Posted 2 hours ago Link to this post

    Hello Gshhar,

    This is because the chart doesn't support showing any additional information except the plotted data. To show the Name and IpAddress and your side you will need to think on how you want to visualize them and then implement this with custom code.

    A possible approach for you could be use a legend, this will allow you to take advantage of the chart's RadLegend support.

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top