This walkthrough illustrates how easily you can bind Barcode Professional to XML data in WPF Applications Barcode Professional for WPF supports both DataBinding model i.e. XAML declarative DataBinding syntax as well as binding in code. In this walkthrough we'll use XAML DataBinding syntax.
Neodynamic Barcode Professional for WPF (any version)
Microsoft .NET Framework 3.0 or greater
Microsoft Visual Studio 2008
Microsoft Visual Basic 2008 Express Edition
Microsoft Visual C# 2008 Express Edition
The data source for our data binding sample will be a simple XML file storing Tech Books info such as Title, Summary, ISBN (International Standard Book Number) code and Cover Image.
During the course of this walkthrough, you will accomplish the following activities:
Please follow these steps:
<Books xmlns="">
<Book ISBN="0-7356-0562-9" Stock="in">
<Title>XML in Action</Title>
<Summary>XML Web Technology</Summary>
<Cover>http://www.microsoft.com/library/images/worldwide/mspress/2461.gif </Cover>
</Book>
<Book ISBN="0-7356-1377-X" Stock="in">
<Title>Introducing Microsoft .NET</Title>
<Summary>Overview of .NET Technology</Summary>
<Cover>http://www.microsoft.com/library/images/worldwide/mspress/5201.gif </Cover>
</Book>
<Book ISBN="0-7356-1288-9" Stock="out">
<Title>Inside C#</Title>
<Summary>C# Language Programming</Summary>
<Cover>http://www.microsoft.com/MSPress/books/imgt/5027.gif </Cover>
</Book>
<Book ISBN="0-7356-1370-2" Stock="in">
<Title>Programming Microsoft Windows With C#</Title>
<Summary>C# Programming using the .NET Framework</Summary>
<Cover>http://www.microsoft.com/MSPress/books/imgt/5188.gif </Cover>
</Book>
<Book ISBN="0-7356-1448-2" Stock="out">
<Title>Microsoft C# Language Specifications</Title>
<Summary>The C# language definition</Summary>
<Cover>http://www.microsoft.com/MSPress/books/imgt/5490.gif </Cover>
</Book>
</Books>
<Window.Resources>
<XmlDataProvider x:Key="BookData" Source="data\bookdata.xml" XPath="Books"/>
<DataTemplate x:Key="BookDataTemplate">
<Border SnapsToDevicePixels="True" Padding="10" Margin="5" CornerRadius="5" BorderThickness="2" BorderBrush="SteelBlue" >
<StackPanel>
<TextBlock Text="{Binding XPath=Title}" FontSize="14" FontWeight="Bold" Margin="0,0,0,5"></TextBlock>
<StackPanel Orientation="Horizontal" Margin="5">
<Image Source="{Binding XPath=Cover}" Width="100"></Image>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="ISBN: " FontWeight="Bold"></TextBlock>
<TextBlock Text="{Binding XPath=@ISBN}" Foreground="OrangeRed"></TextBlock>
</StackPanel>
<TextBlock Text="{Binding XPath=Summary}" Margin="0,5,0,0"></TextBlock>
<my:BarcodeProfessional Symbology="Isbn" Code="{Binding XPath=@ISBN}" EanUpcSupplement="Digits5" EanUpcSupplementCode="90000" Width="170" Height="90" Margin="0" xmlns:my="clr-namespace:Neodynamic.WPF;assembly=Neodynamic.WPF.Barcode" />
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
<Style x:Key="StretchedContainerStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</Window.Resources>
<Grid >
<TextBlock Text="MyBooks - Barcode WPF DataBinding Sample" Padding="5" Height="18" VerticalAlignment="Top" Margin="12,9,171,0"></TextBlock>
<ListBox
ItemsSource="{Binding Source={StaticResource BookData}, XPath=Book}"
ItemTemplate="{StaticResource BookDataTemplate}"
ItemContainerStyle="{StaticResource StretchedContainerStyle}" Margin="12,35,13,12">
</ListBox>
</Grid>
The XAML code is very simple and straightforward. In short, we've coded the following:
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.