Bind to Object to ObjectDataProvider : ObjectDataProvider « Windows Presentation Foundation « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » ObjectDataProvider 
16.102.4.Bind to Object to ObjectDataProvider
<Window x:Class="WpfApplication1.Monitor"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:diag="clr-namespace:System.Diagnostics;assembly=System"
    xmlns:debug="clr-namespace:System.Diagnostics;assembly=WindowsBase"
    Title="Monitor" Height="400" Width="400">
    <Grid>
        <Grid.Resources>
            <ObjectDataProvider x:Key="processes" MethodName="GetProcesses" ObjectType="{x:Type diag:Process}"/>
        </Grid.Resources>
        <ListView Name="listView1" ItemsSource="{Binding Source={StaticResource processes}, debug:PresentationTraceSources.TraceLevel=High}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <WrapPanel>
                        <TextBlock Text="{Binding Path=Id}" MinWidth="80" />
                        <TextBlock Text="{Binding Path=ProcessName}" MinWidth="180" />
                        <TextBlock>
                            <TextBlock.Text>
                                <Binding Path="WorkingSet" />
                            </TextBlock.Text>
                        </TextBlock>
                    </WrapPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes

Namespace WpfApplication1
  Public Partial Class Monitor
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub
  End Class
  Public Class AddPaddingValueConverter
    Implements IValueConverter
    Public Sub New()
    End Sub

    Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfoAs Object Implements IValueConverter.Convert
      Dim As Double = System.Convert.ToDouble(value)
      Return d + 20
    End Function

    Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfoAs Object Implements IValueConverter.ConvertBack
      Dim As Double = System.Convert.ToDouble(value)
      Return d - 20
    End Function
  End Class
End Namespace
WPF Bind To Object To Object Data Provider
16.102.ObjectDataProvider
16.102.1.Create ObjectDataProvider and bind object to it in codeCreate ObjectDataProvider and bind object to it in code
16.102.2.The ObjectDataProvider exposes the enum as a binding sourceThe ObjectDataProvider exposes the enum as a binding source
16.102.3.Set up ObjectDataProvider in codeSet up ObjectDataProvider in code
16.102.4.Bind to Object to ObjectDataProviderBind to Object to ObjectDataProvider
16.102.5.Use Path to reference Bounded object in ItemSourceUse Path to reference Bounded object in ItemSource
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.