Silverlight / WPF - binding data in wpf chart - Asked By Bookworm on 26-Apr-11 02:43 AM

it is the first time for me working with wpf chart

first of all, i want to do a test project which means:

running a qry, fill the dataset, and taking the data to chart

any help?

thnx in advance
Ravi S replied to Bookworm on 26-Apr-11 03:05 AM

Databinding is typically done in XAML by using the {Binding} markup extension. The following example shows a simple binding between the text of a TextBox and a Label that reflects the typed value:

    <TextBox x:Name="txtInput" />
    <Label Content="{Binding Text, ElementName=txtInput, 
                     UpdateSourceTrigger=PropertyChanged}" />

The DataContext property inherits its value to child elements. So you can set the DataContext on a superior layout container and its value is inherited to all child elements. This is very useful if you want to build a form that is bound to multiple properties of the same data object.

<StackPanel DataContext="{StaticResource myCustomer}">
    <TextBox Text="{Binding FirstName}"/>
    <TextBox Text="{Binding LastName}"/>
    <TextBox Text="{Binding Street}"/>
    <TextBox Text="{Binding City}"/>

A typical example is to bind a boolean member to the Visibility property. Since the visibility is an enum value that can be Visible, Collapsed or Hidden, you need a value converter.  <StackPanel> <StackPanel.Resources> <BooleanToVisibilityConverter x:Key="boolToVis" /> </StackPanel.Resources>   <CheckBox x:Name="chkShowDetails" Content="Show Details" /> <StackPanel x:Name="detailsPanel" Visibility="{Binding IsChecked, ElementName=chkShowDetails, Converter={StaticResource boolToVis}}"> </StackPanel> </StackPanel>

The following example shows a simple converter that converts a boolen
to a visibility property. Note that such a converter is already part of
the .NET framework.
  public class BooleanToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Boolean) { return ((bool)value) ? Visibility.Visible : Visibility.Collapsed; }   return value; }   public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }

refer the link below

Hope this helps you...

Asked By Bookworm on 26-Apr-11 03:25 AM
i have this xaml:
<UserControl x:Class="ChartPresentation.Modules.Chart3D"
             d:DesignHeight="367" d:DesignWidth="755" 

        <dxe:TextEdit Name="textEdit1" VerticalAlignment="Bottom" Height="26" Text="Date..." FontSize="12" HorizontalContentAlignment="Right" HorizontalAlignment="Right" Width="156" Foreground="White" ShowBorder="False" Padding="0,0,10,0" Margin="0,0,-1,-2">
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#8C51536C" Offset="0" />
                    <GradientStop Color="Transparent" Offset="1" />
        <dxe:TextEdit FontSize="16" Foreground="White" Height="45" HorizontalContentAlignment="Left" Name="textEdit2" ShowBorder="False" Text="Outstanding balance for LOANS Deposits." VerticalAlignment="Top" Background="#8300002E" Padding="20,0,0,0" IsReadOnly="True" BorderThickness="1" BorderBrush="#FF171783"></dxe:TextEdit>
        <dxc:ChartControl HorizontalAlignment="Stretch" Margin="0,56,0,32" Name="chartControl1" VerticalAlignment="Stretch" Background="{x:Null}" BorderBrush="{x:Null}" Opacity="1">
                <dxc:XYDiagram2D DomainBrush="{x:Null}">
                        <dxc:BarSideBySideSeries2D ShowInLegend="False">
                                <dxc:Quasi3DBar2DModel >
                        <dxc:BarSideBySideSeries2D Name="bars" ShowInLegend="False">
                                <dxc:Quasi3DBar2DModel />
                                <dxc:SeriesPoint Argument="ExxonMobil" Value="362.53"/>
                                <dxc:SeriesPoint Argument="General Electric" Value="348.45"/>
                                <dxc:SeriesPoint Argument="Microsoft" Value="279.02"/>
                                <dxc:SeriesPoint Argument="Citigroup" Value="230.93"/>
                                <dxc:SeriesPoint Argument="Royal Dutch Shell plc" Value="203.52"/>
                                <dxc:SeriesPoint Argument="Procter &amp; Gamble" Value="197.12"/>
                                <dxc:SeriesLabel dxc:BarSideBySideSeries2D.LabelPosition="Outside" />
                                <dxc:Bar2DGrowUpAnimation />
                        <dxc:AxisY2D Foreground="White" />
                        <dxc:AxisX2D Foreground="White" />
                <dxc:DXChartsPalette />

and i have the dataset ds
the chart shows the values with bold,
how can i do to show the values of the dataset???????