TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Martin Mizerák
NA
3
1k
Operations on XML data
Oct 29 2014 11:13 AM
Hello,
I have a big problem.I created application in Visual studio on WPF, which can open and read XML files and show data in datagrid. But i cannot find out how to do mathematical operations with XML data.
My CODE
(XAML)
<Window x:Class="XMLReader.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="XMLReader" Height="370" Width="531">
<Grid>
<TextBox Margin="12,6,104,0" Name="FileNameTextBox" Height="32" VerticalAlignment="Top" />
<Button Content="Open" Margin="0,6,10,0"
Name="button1" Click="button1_Click" HorizontalAlignment="Right" Width="88" Height="32" VerticalAlignment="Top"/>
<DataGrid AutoGenerateColumns="False" Margin="12,53,10,12" Name="dataGrid1" ItemsSource="{Binding Path=Elements[Car]}" Foreground="DarkBlue" HorizontalGridLinesBrush="#00000000" VerticalGridLinesBrush="#00000000" SelectionChanged="dataGrid1_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="Model name 
With VAT" Binding="{Binding Path=Attribute[Name].Value}" />
<DataGridTextColumn Header="Without VAT" Binding="{Binding Path=Attribute[WithountDPH].Value}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
(C#)
namespace XMLReader
{
using System.Xml.Serialization;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void button1_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".xml";
dlg.Filter = "Extended Mark Language (.xml)|*.xml";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
string filename = dlg.FileName;
FileNameTextBox.Text = filename;
var carlist = XElement.Load(filename);
this.dataGrid1.DataContext = carlist;
}
}
}
}
Example of my XML
<Cars>
<Car Name = "FORD FIESTA" SaleDate = "16.12.2000" WithountDPH = "923550" DPH = " 20"/>
<Car Name = "FORD ESCORT/ESCORT DE LUXE/SUPER" SaleDate = "04.10.2014" WithountDPH = "938730" DPH = " 20"/>
<Car Name = "FORD C/CX TEN" SaleDate = "18.04.2010" WithountDPH = "755743" DPH = " 20"/>
<Car Name = "FORD CONSUL I/ZEPHYR I CONVERTIBLE" SaleDate = "05.01.2009" WithountDPH = "605291" DPH = " 20"/>
.
.
.
</Cars>
So my question is, how to multiply "WithoutDPH " column with "DPH" and show results in datagrid.
(DPH = VAT)
Reply
Answers (
2
)
How to save Datagrid in wpf
User Control inside the Tabitem in wpf using mvvm