data template
This commit is contained in:
9
PacticeSolution/DataTemplateSample/App.xaml
Normal file
9
PacticeSolution/DataTemplateSample/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="DataTemplateSample.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:DataTemplateSample"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
17
PacticeSolution/DataTemplateSample/App.xaml.cs
Normal file
17
PacticeSolution/DataTemplateSample/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace DataTemplateSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
10
PacticeSolution/DataTemplateSample/AssemblyInfo.cs
Normal file
10
PacticeSolution/DataTemplateSample/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
15
PacticeSolution/DataTemplateSample/Custom/Test.xaml
Normal file
15
PacticeSolution/DataTemplateSample/Custom/Test.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<UserControl x:Class="DataTemplateSample.Custom.Test"
|
||||
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:local="clr-namespace:DataTemplateSample.Custom"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Hello!"/>
|
||||
<TextBlock Text="This is testing."/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
28
PacticeSolution/DataTemplateSample/Custom/Test.xaml.cs
Normal file
28
PacticeSolution/DataTemplateSample/Custom/Test.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DataTemplateSample.Custom
|
||||
{
|
||||
/// <summary>
|
||||
/// Test.xaml에 대한 상호 작용 논리
|
||||
/// </summary>
|
||||
public partial class Test : UserControl
|
||||
{
|
||||
public Test()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
10
PacticeSolution/DataTemplateSample/DataTemplateSample.csproj
Normal file
10
PacticeSolution/DataTemplateSample/DataTemplateSample.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
28
PacticeSolution/DataTemplateSample/MainWindow.xaml
Normal file
28
PacticeSolution/DataTemplateSample/MainWindow.xaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<Window x:Class="DataTemplateSample.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:DataTemplateSample"
|
||||
xmlns:custom="clr-namespace:DataTemplateSample.Custom"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="200" Width="200">
|
||||
<Window.Resources>
|
||||
<local:Person x:Key="person"/>
|
||||
|
||||
<DataTemplate DataType="{x:Type local:Person}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock>Hello,</TextBlock>
|
||||
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
|
||||
<TextBlock>Your age is </TextBlock>
|
||||
<TextBlock Text="{Binding Age}" FontWeight="Bold"/>
|
||||
<TextBlock>Right?</TextBlock>
|
||||
<custom:Test/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
|
||||
<ContentControl Content="{StaticResource person}">
|
||||
|
||||
</ContentControl>
|
||||
</Window>
|
28
PacticeSolution/DataTemplateSample/MainWindow.xaml.cs
Normal file
28
PacticeSolution/DataTemplateSample/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DataTemplateSample
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
25
PacticeSolution/DataTemplateSample/Person.cs
Normal file
25
PacticeSolution/DataTemplateSample/Person.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataTemplateSample
|
||||
{
|
||||
class Person
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Age { get; set; }
|
||||
|
||||
public Person()
|
||||
{
|
||||
this.Name = "Richard";
|
||||
this.Age = 39;
|
||||
}
|
||||
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return $"{Name} ({Age})";
|
||||
//}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user