티스토리 뷰

반응형

화면을 만들기는 일찍 만들었는데.. 스크롤바 문제 때문에 해결할려고 발버둥을 치다가 좀 늦어지게 되었다. 아함..그렇다고 해결한 것도 아니고..ㅜㅜ.. 그 문제의 해결을 여러분들이 해주실 것이라 상상하며..시작을 할려고 한다.( 그렇게 생각해도 괜찮겠죠? ^^;;; )

 1. 회원관리 화면

간단한 구성으로 만들었다..다만 오른쪽 회원 상세 정보가 들어가는 곳이 화면 크기에 따라서 스크롤바로 움직이도록 만들려고 하다가 6시간정도 허비하다가 GG치고 올리는 중이지만..

1. SL5_BOARD.Web 프로젝트

SL5_BOARD_DBCONTEXT.cs

using System.Data.Entity;
using System.Web;
using System;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace SL5_BOARD.Web.Model
{
    public class SL5_BOARD_DBCONTEXT : DbContext
    {
        public SL5_BOARD_DBCONTEXT()
            : base("SL5_BOARD")
        {
            //디자인타임이 아닌경우
            if (HttpContext.Current == null)
            {
                //데이터베이스 초기화
                Database.SetInitializer<SL5_BOARD_DBCONTEXT>(new SL5_BOARD_DBCONTEXTInitializer());
            }
        }

        public DbSet<MST_MEMBER> MST_MEMBERS { get; set; }
        public DbSet<BOARD_MAIN> BOARD_MAINS { get; set; }
        public DbSet<BOARD_LIST> BOARD_LISTS { get; set; }
        public DbSet<BOARD_REPLY> BOARD_REPLYS { get; set; }
        public DbSet<BOARD_ATTACH> BOARD_ATTACHS { get; set; }

         //모델이 만들어 지면서..테이블과의 관계를 줄 수 있는데..좀 뒤로 미룬다
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
   }

    //데이터베이스를 새로 만들었을 때
    public class SL5_BOARD_DBCONTEXTInitializer : DropCreateDatabaseIfModelChanges<SL5_BOARD_DBCONTEXT>
    {
        //초기값을 넣어준다. - 초기값이 반영되도록 할려면 sdf파일을 삭제하고 다시 실행하면 반영된다.(수동으로 넣으셔도됨)
        protected override void Seed(SL5_BOARD_DBCONTEXT context)
        {
            var admin_member = new MST_MEMBER
            {
                EMAIL = "admin@localhost",
                PASSWORD = "p@ssw0rd",
                MEMBER_NAME = "관리자",
                NICK_NAME = "관리자",
                DESCRIPTION = "사이트 관리하는 슈퍼 유저",
                MEMBER_SCORE = 1000,
                MEMBER_GRADE = "Z",
                STATUS = 1,
                REG_DT = DateTime.Now,
                REG_IDX = 1
            };
            context.MST_MEMBERS.Add(admin_member);
            context.SaveChanges();

            var test_board = new BOARD_MAIN
            {
                BOARD_NAME = "Kakisoft MainPage",
                BOARD_DESC = "Kakisoft Main 페이지 입니다.",
                BOARD_TYPE = "NOR",
                MEMBER_CHECK = false,
                BOARD_STATE = "02",
                BOARD_ORDER = 1,
                REG_DT = DateTime.Now,
                REG_IDX = 1
            };
            context.BOARD_MAINS.Add(test_board);
            context.SaveChanges();
        }
    }
}

2. SL5_BOARDDomainService.cs

MST_MEMBER 일부

#region MST_MEMBER
public IQueryable<MST_MEMBER> GetMstMember()
{
 return this.DbContext.MST_MEMBERS;
}

//이메일과 패스워드를 가지고 로그인 정보 조회 - 나중을 위해서 미리 만들어 놓은 것
public IQueryable<MST_MEMBER> GetMstMemberByLogin(string Email, string Password)
{
 var query = from m in this.DbContext.MST_MEMBERS
    where m.EMAIL == Email && m.PASSWORD == Password
    select m;
 return query.AsQueryable();
}

    //조건을 입력 받아서 해당 해당 레코드만 반환한다.
    public IQueryable<MST_MEMBER> GetMstMemberByCondition(string Condition)
    {
        var query = from m in this.DbContext.MST_MEMBERS
                    where m.MEMBER_NAME.Contains(Condition)
                          || m.EMAIL.Contains(Condition)
                          || m.NICK_NAME.Contains(Condition)
                    select m;

        return query.AsQueryable();
    }

public void InsertBoardList(MST_MEMBER entity)
{
 DbEntityEntry<MST_MEMBER> entityEntry = this.DbContext.Entry(entity);
 if ((entityEntry.State != EntityState.Detached))
 {
  entityEntry.State = EntityState.Added;
 }
 else
 {
  this.DbContext.MST_MEMBERS.Add(entity);
 }
}

public void UpdateBoardList(MST_MEMBER entity)
{
 this.DbContext.MST_MEMBERS.AttachAsModified(entity, this.ChangeSet.GetOriginal(entity), this.DbContext);
}

public void DeleteBoardList(MST_MEMBER entity)
{
 DbEntityEntry<MST_MEMBER> entityEntry = this.DbContext.Entry(entity);
 if ((entityEntry.State != EntityState.Deleted))
 {
  entityEntry.State = EntityState.Deleted;
 }
 else
 {
  this.DbContext.MST_MEMBERS.Attach(entity);
  this.DbContext.MST_MEMBERS.Remove(entity);
 }
}
#endregion

3. SL5_BOARD 프로젝트

Models폴더에 MstMember.cs 추가

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.ServiceModel.DomainServices.Client;
using SL5_BOARD.Resources;
using SL5_BOARD.Web.Model;
using System.Linq;

namespace SL5_BOARD.Models
{
    [Export(typeof(MstMember))]
    public class MstMember : INotifyPropertyChanged
    {
        #region PropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
        #endregion

        [Import(typeof(BoardContext))]
        public BoardContext BoardDomainService { get; set; }

        //너무 길어서 짧게 쓸려고 만들어 놓은것 - 모든 데이터를 가진다.
        public EntitySet<MST_MEMBER> CollectionData
        {
            get
            {
                return BoardDomainService.Context.MST_MEMBERs;
            }
        }

        //현재 선택되어있는 회원
        MST_MEMBER currentData;

        public MST_MEMBER CurrentData
        {
            get
            {
                return currentData;
            }
            set
            {
                if (currentData != value)
                {
                    currentData = value;
                    OnPropertyChanged("CurrentData");
                }
            }
        }

        //조건조회시 사용되는 데이터
        ObservableCollection<MST_MEMBER> conditionData;

        public ObservableCollection<MST_MEMBER> ConditionData
        {
            get
            {
                return conditionData;
            }
            set
            {
                if (conditionData != value)
                {
                    conditionData = value;
                    OnPropertyChanged("ConditionData");
                }
            }
        }

        //메시지 출력용
        string messageData;

        public string MessageData
        {
            get
            {
                return messageData;
            }
            private set
            {
                if (messageData != value)
                {
                    messageData = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "] " + value;
                    OnPropertyChanged("MessageData");
                }
            }
        }

        //최대 회원수
        int maxCount;

        public int MaxCount
        {
            get
            {
                return maxCount;
            }
            private set
            {
                if (maxCount != value)
                {
                    maxCount = value;
                    OnPropertyChanged("MaxCount");
                }
            }
        }

        //생성자
        public MstMember()
        {
            this.PropertyChanged += new PropertyChangedEventHandler(MstMember_PropertyChanged);
        }

        //현재 모델에서 발생한 프로퍼티체인지 이벤트 처리 - 다른 프로퍼티 변경작업시 사용
        void MstMember_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            }
        }

        //전체 회원 조회
        public void Getting()
        {
            BoardDomainService.Context.GetMstMemberQuery().IncludeTotalCount = true;
            //Load가 완료되면 loadComplete 함수로 콜백됨
            BoardDomainService.Context.Load(
                                            BoardDomainService.Context.GetMstMemberQuery(),
                                            LoadBehavior.RefreshCurrent,
                                            load =>
                                            {
                                                loadComplete(load);
                                            },
                                            true);
        }

        //조건으로 회원 조회
        public void Getting(string Condition)
        {
            if (Condition.Length > 0)
            {
                //조건이 있을 때는 이걸 호출하고
                BoardDomainService.Context.Load(
                                                BoardDomainService.Context.GetMstMemberByConditionQuery(Condition),
                                                LoadBehavior.RefreshCurrent,
                                                load =>
                                                {
                                                    loadComplete(load);
                                                },
                                                true);
            }
            else
            {
                //조건이 없을 대는 그냥 전체 호출
                Getting();
            }
        }

        //로그인
        public void Login(string email, string password)
        {
            //로그인시 이메일과 비밀번호를 쿼리에 넣어서 보내야함.(쿼리도 바꿔주고)
            if (BoardDomainService.Context.IsLoading == false)
            {
                BoardDomainService.Context.Load(
                                                BoardDomainService.Context.GetMstMemberQuery(),
                                                LoadBehavior.RefreshCurrent,
                                                load =>
                                                {
                                                    loadComplete(load);
                                                },
                                                true);
            }
            else
            {
                MessageData = "조회 중이니 잠시 후 다시 시도해 주시기 바랍니다.";
            }
        }

        //로드 완료 콜벡 함수
        protected void loadComplete(LoadOperation lo)
        {
            if (lo.HasError == false)
            {
                //작업 성공
                if (lo.TotalEntityCount > 0)
                {
                    MessageData = "작업 성공";

                    //ConditionData를 만드는 방법 2가지
                    //1번방법 : LINQ 사용
                    //반환된 모든 엔티티를 캐스트 하는 것을 쿼리로 만들고
                    var query = from l in lo.AllEntities.Cast<MST_MEMBER>()
                                select l;
                    //컨디션 데이터를 클리어하고
                    if (ConditionData == null)
                        ConditionData = new ObservableCollection<MST_MEMBER>();
                    ConditionData.Clear();
                    //쿼리를 리스트로 변경하고, 컨데션 데이터에 하나씩 끄집어 넣음
                    query.ToList().ForEach(p => ConditionData.Add(p));

                   
                    //2번방법 : 바로 옵져블컬렉션으로 만들기
                    //한줄로 간단하게
                    //ConditionData = new ObservableCollection<MST_MEMBER>(lo.AllEntities.Cast<MST_MEMBER>());


                    //여긴 반환된 쿼리 이름을 가지고 쿼리마다 뭔가 처리를 할 수 있음
                    //switch (lo.EntityQuery.QueryName)
                    //{
                    //    case "GetMstMember":
                    //        break;
                    //    case "GetMstMemberByConditionQuery":
                    //        break;
                    //    default:
                    //        break;
                    //}
                }
                else
                {
                    ConditionData = null;
                }
            }
            else
            {
                //실행했던 쿼리 이름을 가지고 결과 처리
                MessageData = "작업 실패";
                switch (lo.EntityQuery.QueryName)
                {
                    case "GetMstMemberByConditionQuery":
                        break;
                    default:
                        //로그인 실패
                        MessageData = "메일 주소와 비밀번호를 확인해 주시기 바랍니다.";
                        break;
                }
            }

        }

        //회원추가
        public void Adding(MST_MEMBER mm)
        {
            if (mm != null && mm is MST_MEMBER)
            {
                mm.REG_DT = DateTime.Now;
                mm.REG_IDX = 1;
                BoardDomainService.Context.MST_MEMBERs.Add(mm);
                CurrentData = mm;
            }
            else
            {
                MessageData = "데이터가 없거나 형식이 다릅니다.";
            }
        }

        //회원삭제
        public void Removing(MST_MEMBER mm)
        {
            if (mm != null && mm is MST_MEMBER)
            {
                BoardDomainService.Context.MST_MEMBERs.Remove(mm);
            }
            else
            {
                MessageData = "데이터가 없거나 형식이 다릅니다.";
            }
        }

        //회원 정보 저장
        public void Saving()
        {
            BoardDomainService.Context.SubmitChanges(submitCallBack, null);
        }

        //저장완료 콜백 함수
        private void submitCallBack(SubmitOperation so)
        {
            if (so.IsComplete == true)
            {
                MessageData = "작업을 완료 했습니다.";
            }
            else
            {
                MessageData = "작업을 실패 했습니다.";
            }
        }

        //수정 취소
        public void Canceling()
        {
            BoardDomainService.Context.RejectChanges();
        }
    }
}

4. MstMemberViewModel.cs

using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Windows.Input;
using Microsoft.Expression.Interactivity.Core;
using SL5_BOARD.Models;
using SL5_BOARD.Web.Model;
using System.Windows.Controls;

namespace SL5_BOARD.ViewModels
{
    [Export(typeof(MstMemberViewModel))]
    public class MstMemberViewModel : INotifyPropertyChanged
    {
        #region PropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
        #endregion

        //회원 마스터 모델 임포트
        [Import(typeof(MstMember))]
        public MstMember MstMemberData { get; set; }

        //생성자
        public MstMemberViewModel()
        {
        }

        //회원 전체 조회
        ICommand selectCommand;
        public ICommand SelectCommand
        {
            get
            {
                if (selectCommand == null)
                {
                    selectCommand = new ActionCommand(() =>
                    {
                        MstMemberData.Getting();
                    });
                }
                return selectCommand;
            }
        }
        public void Select()
        {
            MstMemberData.Getting();
        }

        //조건을 가지는 조회 커맨드
        ICommand selectConditionCommand;
        public ICommand SelectConditionCommand
        {
            get
            {
                if (selectConditionCommand == null)
                {
                    selectConditionCommand = new ActionCommand(condition =>
                    {
                        //조건을 가지는 회원 조회 함수 실행
                        MstMemberData.Getting(condition as string);
                    });
                }
                return selectConditionCommand;
            }
        }

        //회원 추가
        ICommand addCommand;
        public ICommand AddCommand
        {
            get
            {
                if (addCommand == null)
                {
                    addCommand = new ActionCommand(() =>
                    {
                        MST_MEMBER obj = new MST_MEMBER();
                        MstMemberData.Adding(obj);
                    });
                }
                return addCommand;
            }
        }

        //회원 삭제
        ICommand removeCommand;
        public ICommand RemoveCommand
        {
            get
            {
                if (removeCommand == null)
                {
                    removeCommand = new ActionCommand(p =>
                    {
                        if (p != null)
                        {
                            MST_MEMBER obj = p as MST_MEMBER;
                            MstMemberData.Removing(obj);
                        }
                    });
                }
                return removeCommand;
            }
        }

        //저장
        ICommand saveCommand;
        public ICommand SaveCommand
        {
            get
            {
                if (saveCommand == null)
                {
                    saveCommand = new ActionCommand(() =>
                    {
                        MstMemberData.Saving();
                    });
                }
                return saveCommand;
            }
        }

        //취소
        ICommand cancelCommand;
        public ICommand CancelCommand
        {
            get
            {
                if (cancelCommand == null)
                {
                    cancelCommand = new ActionCommand(() =>
                    {
                        MstMemberData.Canceling();
                    });
                }
                return cancelCommand;
            }
        }

        //회원 변경
        ICommand selectChanged;
        public ICommand SelectChangedCommand
        {
            get
            {
                if (selectChanged == null)
                {
                    selectChanged = new ActionCommand(para => SelectChangedOperation(para));
                }
                return selectChanged;
            }
        }
        private void SelectChangedOperation(object para)
        {
            MstMemberData.CurrentData = para as MST_MEMBER;
        }

        //로그인
        ICommand loginCommand;
        public ICommand LoginCommand
        {
            get
            {
                if (loginCommand == null)
                {
                    loginCommand = new ActionCommand(pnl => LoginOperation(pnl));
                }
                return loginCommand;
            }
        }

        //로그인시에 사용할 예정인데..아직 미완성
        private void LoginOperation(object pnl)
        {
            StackPanel sp = pnl as StackPanel;
            string email;
            string password;

            MstMemberData.Getting();
        }
    }
}

5. MstMemberView.xaml

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:SL5_BOARD_Converter="clr-namespace:SL5_BOARD.Converter"

xmlns:SL5_BOARD_ViewModels="clr-namespace:SL5_BOARD.ViewModels" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

x:Name="userControl"

x:Class="SL5_BOARD.Views.MstMemberView"
    mc:Ignorable="d"
    d:DesignHeight="500" d:DesignWidth="600">
   
 <UserControl.Resources>

  <!--이 변환 함수는 없어도 상관없음..실패작-->
  <SL5_BOARD_Converter:ActualHeightToHeightConverter x:Key="ActualHeightToHeightConverter"/>
  <SL5_BOARD_Converter:ValueToBoolConverter x:Key="ValueToBoolConverter"/>
 </UserControl.Resources>
   
 <Grid x:Name="LayoutRoot" Background="White">
  <i:Interaction.Triggers>
   <i:EventTrigger>

    <!--로드되고 바로 데이터 뿌리기 위해-->
    <i:InvokeCommandAction Command="{Binding SelectCommand, Mode=OneWay}"/>
   </i:EventTrigger>
  </i:Interaction.Triggers>

  <Grid.ColumnDefinitions>
   <ColumnDefinition Width="192"/>
   <ColumnDefinition/>
  </Grid.ColumnDefinitions>

   <Grid.RowDefinitions>
   <RowDefinition Height="38"/>
   <RowDefinition Height="35"/>
   <RowDefinition Height="28"/>
   <RowDefinition/>
   <RowDefinition Height="35"/>
  </Grid.RowDefinitions>

  <Grid.DataContext>
   <SL5_BOARD_ViewModels:MstMemberViewModel/>
  </Grid.DataContext>

   <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="회원 관리" FontSize="14.667" FontWeight="Bold" Foreground="{StaticResource ForeColor_Blues}" Margin="10,6,0,10" d:LayoutOverrides="Height"/>
  <Path Data="M0,30 L400,30" Fill="#FF5181B9" Height="3" Margin="0" Stretch="Fill" Stroke="#FF5181B9" UseLayoutRounding="False" VerticalAlignment="Bottom" StrokeLineJoin="Bevel" StrokeThickness="3" Grid.ColumnSpan="2"/>
  <Button x:Name="btnSelect" Content="조회" HorizontalAlignment="Right" Margin="0,6,8,7" Width="70" Grid.Column="1" Grid.Row="1" Height="22" Command="{Binding SelectCommand, Mode=OneWay}" IsEnabled="False"/>
  <Path Data="M0,30 L400,30" Fill="{StaticResource ForeColor_Kakis}" Stretch="Fill" Stroke="{StaticResource ForeColor_Kakis}" UseLayoutRounding="False" StrokeLineJoin="Bevel" StrokeThickness="3" Grid.ColumnSpan="2" Grid.Row="1" Height="3" VerticalAlignment="Bottom" Margin="0,0,0,-1"/>
  <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="회원 목록" FontSize="12" FontWeight="Bold" Foreground="{StaticResource ForeColor_Kakis}" Margin="10,7,0,3" Grid.Row="2" d:LayoutOverrides="Height"/>


  <ListBox x:Name="lbBoardMain" Margin="8,30,8,8" Grid.Row="3" BorderBrush="{x:Null}" ItemsSource="{Binding MstMemberData.ConditionData}" ItemTemplate="{StaticResource MemberDataTemplate}">
   <i:Interaction.Triggers>
    <i:EventTrigger EventName="SelectionChanged">
     <i:InvokeCommandAction Command="{Binding SelectChangedCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem, ElementName=lbBoardMain}"/>
    </i:EventTrigger>
   </i:Interaction.Triggers>
  </ListBox>


  <TextBlock TextWrapping="Wrap" Text="회원 상세 정보" FontSize="12" FontWeight="Bold" Foreground="{StaticResource ForeColor_Kakis}" Margin="8,8,0,2" Grid.Row="2" HorizontalAlignment="Left" Grid.Column="1" d:LayoutOverrides="Height"/>
  <Button x:Name="btnSearch" Content="조회" Margin="0,2,8,0" Grid.Row="3" VerticalAlignment="Top" HorizontalAlignment="Right" Width="70" Height="22" Command="{Binding SelectConditionCommand, Mode=OneWay}" CommandParameter="{Binding Text, ElementName=textBox}"/>
  <Button x:Name="btnSave" Content="저장" Margin="0,3,82,3" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" Width="70">
   <i:Interaction.Triggers>
    <i:EventTrigger EventName="Click">
     <i:InvokeCommandAction Command="{Binding SaveCommand, Mode=OneWay}"/>
    </i:EventTrigger>
   </i:Interaction.Triggers>
  </Button>

   <Border x:Name="border" Grid.Column="1" Grid.Row="3" BorderBrush="Black" BorderThickness="2" Margin="0" >
   <ScrollViewer Height="{Binding ActualHeight, ElementName=border, Mode=OneWay}" >
    <StackPanel x:Name="spMstMemberInfo" DataContext="{Binding MstMemberData.CurrentData}" ScrollViewer.VerticalScrollBarVisibility="Visible" Margin="2" Height="420">
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="메일주소" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding EMAIL, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="회원명" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding MEMBER_NAME, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0" Text="별칭"/>
      <TextBox TextWrapping="Wrap" Text="{Binding NICK_NAME, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="메일링가입" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <CheckBox Content="{Binding EMAIL_RECEIVE}" VerticalAlignment="Center" IsChecked="{Binding EMAIL_RECEIVE, Mode=TwoWay}" IsHitTestVisible="False"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28" >
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="소개" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding DESCRIPTION, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True" AcceptsReturn="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="마지막로그인" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding LAST_LOGIN_DT, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="직업" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding JOB, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="취미" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding HOBBY, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="관심분야" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding INTEREST, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="회원점수" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding MEMBER_SCORE, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="회원등급" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding MEMBER_GRADE, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="비고사항" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding ETC, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="상태" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding STATUS, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="등록일시" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding REG_DT, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
     <StackPanel Orientation="Horizontal" Height="28">
      <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="10,0,0,0"/>
      <TextBlock TextWrapping="Wrap" Text="수정일시" FontSize="12" VerticalAlignment="Center" Width="90" Padding="5,0,0,0"/>
      <TextBox TextWrapping="Wrap" Text="{Binding UPT_DT, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Center" Style="{StaticResource NormalTextBoxStyle}" IsReadOnly="True"/>
     </StackPanel>
    </StackPanel>
   </ScrollViewer>
  </Border>

  <Button x:Name="btnCancel" Content="취소" Margin="0,3,8,3" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" Width="70">
   <i:Interaction.Triggers>
    <i:EventTrigger EventName="Click">
     <i:InvokeCommandAction Command="{Binding CancelCommand, Mode=OneWay}"/>
    </i:EventTrigger>
   </i:Interaction.Triggers>
  </Button>

  <TextBlock Margin="8,6,82,8" Grid.Row="1" TextWrapping="Wrap" Text="{Binding MstMemberData.MessageData, Mode=OneWay}" Grid.ColumnSpan="2" VerticalAlignment="Center" FontSize="12" Height="18"/>


  <TextBox x:Name="textBox" TextWrapping="Wrap" Text="{Binding BOARD_NAME, Mode=TwoWay}" Foreground="{StaticResource NormalForeColor}" BorderThickness="0,0,0,1" FontSize="12" VerticalAlignment="Top" Style="{StaticResource NormalTextBoxStyle}" Margin="10,1,82,0" Grid.Row="3"/>

 </Grid>
</UserControl>

6. MstMemberView.xaml.cs

using System.ComponentModel.Composition;
using System.Windows.Controls;
using SL5_BOARD.ViewModels;

namespace SL5_BOARD.Views
{
    public partial class MstMemberView : UserControl
    {
        [Import(typeof(MstMemberViewModel))]
        public MstMemberViewModel MstMemberVM { get; set; }

        public MstMemberView()
        {
            InitializeComponent();

            CompositionInitializer.SatisfyImports(this);

            LayoutRoot.DataContext = MstMemberVM;
        }
    }
}

7.  MainPage.cs

using System;
using System.Linq;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;

using SL5_BOARD.Views;
using SL5_BOARD.ViewModels;
using System.ComponentModel.Composition;

namespace SL5_BOARD
{
    public partial class MainPage : UserControl
    {
        //메인 페이지 뷰모델 임포트
        [Import(typeof(MainPageViewModel))]
        public MainPageViewModel MainPageVM { get; set; }

        public MainPage()
        {
            InitializeComponent();

            //보드메인뷰는 아직은 그냥 마구잡이 생성해서 붙여 놓음
            //UserControl uc = new BoardMainView();
            UserControl uc = new MstMemberView();
            IcMain.Items.Add(uc);

 

            //임포트 초기화 : 이명령은 뷰단에서 한번 실행되면, 그 하위 컴포넌트 들도 차례대로 인스턴스화 된다.
            CompositionInitializer.SatisfyImports(this);

            //메인페이지 뷰모델을 LayoutRoot의 DataContext에 바인딩
            LayoutRoot.DataContext = MainPageVM;
        }
    }
}

8. 엄청난 양의 소스인데..
음..이렇게 올렸는데두 불구하고 빠진 부분이 있을 것 같은..불길한 예감이..추가로 필요한 부분은 리플로 요청하도록 하면된다..이 곳에서 중요하게 보아야 할 부분은 조건 검색 후 처리 방법이다. 어떤 식으로 처리가 되고 있는지...쭈욱 따라가 보면서 내용을 확인해 보자.

추가

BoardResourceDictionary.xaml 에 추가

 <DataTemplate x:Key="MemberDataTemplate">
  <Grid>
   <Border MinHeight="22">
    <StackPanel Orientation="Horizontal">
     <Ellipse Fill="#FF666666" Stroke="Black" Width="5" Height="5" VerticalAlignment="Center" Margin="6,0,0,0"/>
     <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Margin="6,0,0,0" Foreground="{StaticResource NormalForeColor}" Text="{Binding MEMBER_NAME}"/>
     <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Margin="6,0,0,0" Foreground="{StaticResource NormalForeColor}" Text="{Binding EMAIL}"/>
    </StackPanel>
   </Border>
  </Grid>
 </DataTemplate>

반응형
댓글