티스토리 뷰
https://www.youtube.com/watch?v=xUwk2-_tRzo
View 폴더 - 사용자정의컨트롤로 FirstView, SecondView, ThirdView를 생성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | <Window x:Class="MVVM_MultipleView.MainWindow" 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:local="clr-namespace:MVVM_MultipleView" xmlns:viewmodels="clr-namespace:MVVM_MultipleView.ViewModel" xmlns:views="clr-namespace:MVVM_MultipleView.View" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> ------------------------------------------------------------------------------------------------- <Window.Resources> <DataTemplate x:Name="firstViewTemplate" DataType="{x:Type viewmodels:FirstViewModel}"> <views:FirstView DataContext="{Binding}"/> </DataTemplate> <DataTemplate x:Name="secondViewTemplate" DataType="{x:Type viewmodels:SecondViewModel}"> <views:SecondView DataContext="{Binding}"/> </DataTemplate> <DataTemplate x:Name="thirdViewTemplate" DataType="{x:Type viewmodels:ThirdViewModel}"> <views:ThirdView DataContext="{Binding}"/> </DataTemplate> </Window.Resources> ------------------------------------------------------------------------------------------------- <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <DockPanel Background="Gray" Grid.Row="0" Grid.Column="0" Grid.RowSpan="5"> <StackPanel> <Button Content="First" Click="FirstView_Clicked"></Button> <Button Content="Second" Click="SecondView_Clicked"></Button> <Button Content="Third" Click="ThirdView_Clicked"></Button> </StackPanel> </DockPanel> <ContentControl Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="4" Grid.RowSpan="5" Content="{Binding }"></ContentControl> </Grid> </Window> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using MVVM_MultipleView.ViewModel; namespace MVVM_MultipleView { /// <summary> /// MainWindow.xaml에 대한 상호 작용 논리 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void FirstView_Clicked(object sender, RoutedEventArgs e) { DataContext = new FirstViewModel(); } private void SecondView_Clicked(object sender, RoutedEventArgs e) { DataContext = new SecondViewModel(); } private void ThirdView_Clicked(object sender, RoutedEventArgs e) { DataContext = new ThirdViewModel(); } } } | cs |
'C# > WPF' 카테고리의 다른 글
MVVM 예제2 - WPF JSON ListView + MVVM (0) | 2017.07.10 |
---|---|
MVVM 기본 세팅 (0) | 2017.07.09 |
MVVM 예제1 (0) | 2017.07.09 |
WPF tutorial - ListView sorting (0) | 2017.07.04 |
WPF tutorial - ListView grouping (0) | 2017.07.04 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 데이터 바인딩
- DP
- dfs
- XAML
- CollectionView
- listview
- UIView Animation
- FEED
- WPF
- Grid
- 백준
- 스택
- BOJ
- command
- Add TapGesture
- BFS
- 문자열
- 백준온라인
- 그래프
- 코딩야학
- 타일링
- C++
- 생활코딩
- Custom Cell
- Fakebook
- 객체
- CustomCollectionViewCell
- MVVM
- Cell Animation
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함