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

Hello
everybody
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
HI


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:

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

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}"/>
</StackPanel>


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
http://www.wpftutorial.net/DataBindingOverview.html
http://coredotnet.blogspot.com/2006/05/wpf-data-binding-tutorial.html
http://www.nbdtech.com/Blog/archive/2009/02/02/wpf-xaml-data-binding-cheat-sheet.aspx

Hope this helps you...


Asked By Bookworm on 26-Apr-11 03:25 AM
i have this xaml:
<UserControl x:Class="ChartPresentation.Modules.Chart3D"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="367" d:DesignWidth="755" 
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
             xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts">
    <Grid>

        <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">
            <dxe:TextEdit.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#8C51536C" Offset="0" />
                    <GradientStop Color="Transparent" Offset="1" />
                </LinearGradientBrush>
            </dxe:TextEdit.Background>
        </dxe:TextEdit>
        <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:ChartControl.Diagram>
                <dxc:XYDiagram2D DomainBrush="{x:Null}">
                    <dxc:XYDiagram2D.SeriesTemplate>
                        <dxc:BarSideBySideSeries2D ShowInLegend="False">
                            <dxc:BarSideBySideSeries2D.Model>
                                <dxc:Quasi3DBar2DModel >
                                    
                                </dxc:Quasi3DBar2DModel>
                            </dxc:BarSideBySideSeries2D.Model>
                        </dxc:BarSideBySideSeries2D>
                    </dxc:XYDiagram2D.SeriesTemplate>
                    <dxc:XYDiagram2D.Series>
                        <dxc:BarSideBySideSeries2D Name="bars" ShowInLegend="False">
                            <dxc:BarSideBySideSeries2D.Model>
                                <dxc:Quasi3DBar2DModel />
                            </dxc:BarSideBySideSeries2D.Model>
                            <dxc:BarSideBySideSeries2D.Points>
                                <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:BarSideBySideSeries2D.Points>
                            <dxc:BarSideBySideSeries2D.Label>
                                <dxc:SeriesLabel dxc:BarSideBySideSeries2D.LabelPosition="Outside" />
                            </dxc:BarSideBySideSeries2D.Label>
                            <dxc:BarSideBySideSeries2D.PointAnimation>
                                <dxc:Bar2DGrowUpAnimation />
                            </dxc:BarSideBySideSeries2D.PointAnimation>
                        </dxc:BarSideBySideSeries2D>
                    </dxc:XYDiagram2D.Series>
                    <dxc:XYDiagram2D.AxisY>
                        <dxc:AxisY2D Foreground="White" />
                    </dxc:XYDiagram2D.AxisY>
                    <dxc:XYDiagram2D.AxisX>
                        <dxc:AxisX2D Foreground="White" />
                    </dxc:XYDiagram2D.AxisX>
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
            <dxc:ChartControl.Palette>
                <dxc:DXChartsPalette />
                
        
            </dxc:ChartControl.Palette>
        </dxc:ChartControl>
    </Grid>
</UserControl>

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