2013-01-09 6 views
0

우선, 나는 정말 초보자입니다. WPF에서 Data Binding에 대해 들어 본적이 없습니다.WPF에서 초급 좌절, 특히 데이터 바인딩에

블로그 및 MSDN에서 배우려고했지만, 나는 이해를 얻을 수 없습니다. 데이터 바인딩은 WPF에 관한 혼란 중 하나이지만 지금 당장 이해해야 할 중요한 부분입니다. 나는 지금까지 CustomerDL.vb (데이터 액세스 계층) 는 (비즈니스 계층) FormCustomer.xaml (프리젠 테이션 레이어)

, 내가 지금입니다 CustomerBL.vb 유일한 개념 :

내가 이러한 클래스를 가지고 말 배우십시오 : DL-> BL-> PL.

여기 내 PL입니다 :

Public Class FrmEmployee2 
    Public Sub New() 
     InitializeComponent() 

     MasterEmployeeBL = New MasterEmployeeBL 
     Employees = MasterEmployeeBL.FetchAllEmployee() 

     MainGrid.DataContext = Employees 
    End Sub 

    Private _employees As List(Of Employee) 
    Public Property Employees() As List(Of Employee) 
     Get 
      Return _employees 
     End Get 
     Set(ByVal value As List(Of Employee)) 
      _employees = value 
     End Set 
    End Property 

    Public MasterEmployeeBL As MasterEmployeeBL 
End Class 

그리고 이것은 내 WPF입니다 :

<dx:DXWindow x:Class="FrmFindEmployee2" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
    xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" 
    xmlns:dxd="http://schemas.devexpress.com/winfx/2008/xaml/docking" 
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
    xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys" 
    xmlns:local="clr-namespace:BMT_WPF" 
    dx:ThemeManager.ThemeName="MetropolisDark" 
    Title="Find Employee" Height="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height}" Width="658" 
    WindowStartupLocation="CenterScreen" SizeToContent="Width"> 

    <Window.Resources> 
     <ResourceDictionary> 
      <local:BooleanToStatusConverter x:Key="BoolToStatusConv" /> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="/BMT-WPF;component/Helpers/EditStyles.xaml" />  
      </ResourceDictionary.MergedDictionaries> 
     </ResourceDictionary> 
    </Window.Resources> 

    <Grid x:Name="MainGrid" DataContext="{Binding Source=Employees}"> 
     <DockPanel> 
      <dxg:GridControl ItemsSource="{Binding}" AutoPopulateColumns="True"> 

      </dxg:GridControl> 
     </DockPanel> 
    </Grid> 
</dx:DXWindow> 

내가이 내 GridControl 직원 목록을 결합하기에 충분하다고 가정하지만, 아무것도 표시되지 않습니다.

아무도 내가 초보자 용으로 WPF에 대해 배울 수있는 좋은 리소스를 지적 할 수 있습니까?

긴 게시물을 위해 죄송합니다. 건배! :)

답변

1

MainGrid의 DataContext를 두 번, 코드에서 한 번, XAML에서 한 번 설정했습니다. 이 요소에서 XAML 바인딩을 제거하는 것이 좋습니다. 데이터 바인딩에 대한 기본적인 튜토리얼

, 내가 쓴이 블로그 게시물 시도 : 나는 데이터 선언 할 때 매력 : 가 당신이 나에게 설명 할 수처럼 일

http://www.scottlogic.co.uk/blog/colin/2012/04/everything-you-wanted-to-know-about-databinding-in-wpf-silverlight-and-wp7-part-one/

+0

가 왜 잘못된 것을 양쪽 장소의 문맥? 데이터 컨텍스트, xaml 또는 배후 코드를 설정하는 것이 더 적절합니까? –