'control'에 해당되는 글 5건
- 2009/07/03 Silverlight – Custom control
- 2009/06/23 Silverlight Custom control
- 2009/04/28 Silverlight domain access control
- 2009/02/02 iTunes Data Grid Skin for ASP.NET GridView, ListView Control
- 2007/08/14 HTTP Header Cache Control
이번엔 실버라이트 사용자 컨트롤을 만들어봅니다.
설명이 많이 부족하지만 따라하시다보면 성공하실수.....
사실 제가 부족해서 설명이 많이 부족하네요ㅠㅠ
Generic.xaml
-
Custom Control의 기본 모양을 정의하는 파일
-
Xmlns와 xmlns:x는 page.xaml에서 가져온다
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>
public class MyControl : Control
{
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}
}
Control을 상속 받고
기본 스타일 키를 현재 형식의 타입을 지정한다.
재정의할 메소드가 있는데, OnApplyTemplate 을 override 하여 메소드를 만든다
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}
이제 Generic.xaml에서 내가 작성하는 control의 네임스페이스를 지정한다.
My로 prefix를 주었으므로 my를 앞으로 사용하게 된다
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:CustomControlTest2"
>
<Style TargetType="my:MyControl">
</Style>
</ResourceDictionary>
이제 컨트롤의 템플릿을 만든다
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:CustomControlTest2"
>
<Style TargetType="my:MyControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="my:MyControl">
<Grid>
<TextBlock x:Name="MyText" Text="안녕?" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
이제 기본적인 내용은 끝났고 Grid 안에 내용을 지정한다.
이제 컨트롤에서 속성을 노출할 수 있도록 작성해보자.
propdp를 입력하면 인텔리센스로 작성할 수 있다.
마지막에 UIxxxxxxx(0) 라고 나오는 부분은 지워주고 PropertyMetadata 로 변경해야한다.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace CustomControlTest2
{
public class MyControl : Control
{
TextBlock _tb = null;
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(
"Text",
typeof(string),
typeof(MyControl),
new PropertyMetadata(new PropertyChangedCallback(
// e는 보낸쪽
(d, e) =>
{
MyControl myControl = d as MyControl;
if (myControl != null && myControl._tb != null)
{
myControl._tb.Text = e.NewValue.ToString();
}
})
)
);
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
// 컨트롤에 들어 있는 TextBlock을 가져온다.
_tb = GetTemplateChild("MyText") as TextBlock;
if (_tb !=null)
{
_tb.Text = "커스텀 컨트롤~!";
}
}
}
}
이제 Page.xaml에 돌아와서 MyControl을 작성해 보자
<UserControl x:Class="CustomControlTest2.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:CustomControlTest2"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<my:MyControl Text="여기에 글을 작성해보자!!"></my:MyControl>
</Grid>
</UserControl>
'.NET > Silverlight' 카테고리의 다른 글
| Silverlight - Network Sample 2 (0) | 2009/07/15 |
|---|---|
| Silverlight - Network Example 1 (0) | 2009/07/13 |
| Silverlight – Custom control (0) | 2009/07/03 |
| Silverlight Custom control (0) | 2009/06/23 |
| Silverlight – bubbling events (2) | 2009/05/18 |
| Silverlight – DispatcherTimer , Clock (0) | 2009/05/12 |
이번에는 Silverlight의 컨트롤을 정의해서 만들어봅니다.
예전에 강의들을 때 작성하고 다시보니 무슨소린지 모르겠네요.. ㅋㅋㅋ
그래도 전혀 무지한 것 보단 캡쳐라도 약간 있으니 ㅠㅠ 나중에 약간이라도 도움될 듯..
부족하지만 1%라도 얻을게 있을지 모르니 정리 안된 상태로 등록합니다... ㅋㅋ
Generic.xaml
-
Custom Control의 기본 모양을 정의하는 파일
-
Xmlns와 xmlns:x는 page.xaml에서 가져온다
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>
public class MyControl : Control
{
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}
}
Control을 상속 받고
기본 스타일 키를 현재 형식의 타입을 지정한다.
재정의할 메소드가 있는데, OnApplyTemplate 을 override 하여 메소드를 만든다
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}
이제 Generic.xaml에서 내가 작성하는 control의 네임스페이스를 지정한다.
my로 prefix를 주었으므로 my를 앞으로 사용하게 된다
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:CustomControlTest2"
>
<Style TargetType="my:MyControl">
</Style>
</ResourceDictionary>
이제 컨트롤의 템플릿을 만든다
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:CustomControlTest2"
>
<Style TargetType="my:MyControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="my:MyControl">
<Grid>
<TextBlock x:Name="MyText" Text="안녕?" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
이제 기본적인 내용은 끝났고 Grid 안에 내용을 지정한다.
이제 컨트롤에서 속성을 노출할 수 있도록 작성해보자.
propdp를 입력하면 인텔리센스로 작성할 수 있다.
마지막에 UIxxxxxxx(0) 라고 나오는 부분은 지워주고 PropertyMetadata 로 변경해야한다.
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace CustomControlTest2
{
public class MyControl : Control
{
TextBlock _tb = null;
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(
"Text",
typeof(string),
typeof(MyControl),
new PropertyMetadata(new PropertyChangedCallback(
// e는 보낸쪽
(d, e) =>
{
MyControl myControl = d as MyControl;
if (myControl != null && myControl._tb != null)
{
myControl._tb.Text = e.NewValue.ToString();
}
})
)
);
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
// 컨트롤에 들어 있는 TextBlock을 가져온다.
_tb = GetTemplateChild("MyText") as TextBlock;
if (_tb !=null)
{
_tb.Text = "커스텀 컨트롤~!";
}
}
}
}
이제 Page.xaml에 돌아와서 MyControl을 작성해 보자
<UserControl x:Class="CustomControlTest2.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:CustomControlTest2"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<my:MyControl Text="여기에 글을 작성해보자!!"></my:MyControl>
</Grid>
</UserControl>
'.NET > Silverlight' 카테고리의 다른 글
| Silverlight - Network Example 1 (0) | 2009/07/13 |
|---|---|
| Silverlight – Custom control (0) | 2009/07/03 |
| Silverlight Custom control (0) | 2009/06/23 |
| Silverlight – bubbling events (2) | 2009/05/18 |
| Silverlight – DispatcherTimer , Clock (0) | 2009/05/12 |
| Silverlight – Dynamic Page load (0) | 2009/05/10 |
실버라이트에서는 clientaccesspolicy.xml 파일을 이용해서 사용자 접근을 제어한다.
다음과 같이 예를 보면,
http://hugeflow.com/clientaccesspolicy.xml
silverlight 호스트 하는 서버의 사용자 접근에 대한 접근제어를 지정한다
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
FLEX에서의 접근제어는 crossdomain.xml 파일을 이용한다.
http://www.yahoo.com/crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*.yahoo.com" secure="false" />
</cross-domain-policy>
'.NET > Silverlight' 카테고리의 다른 글
| Silverlight - Access managed code form javascript (0) | 2009/05/05 |
|---|---|
| Silverlight - Network (2) | 2009/04/30 |
| Silverlight domain access control (0) | 2009/04/28 |
| REMIX08 RIA, UX의 세계 (0) | 2008/06/16 |
| Programming Silverlight with JavaScript (0) | 2008/05/28 |
| Silver light와 Flickr 를 이용한 Image 슬라이드 (0) | 2008/02/13 |
iTunes Data Grid Skin for ASP.NET GridView, ListView Control

Demo page : http://mattberseth2.com/demo/Default.aspx?Name=iTunes+Data+Grid+Skin&Filter=All
위와 같은 형태로 GridView, ListView를 출력하도록 도와주네요.
Sort 되는 부분은 jQuery를 혼용해서 처리하도록 했구요 .
가져다 쓰기 좋은 내용이라 스크랩을 ^ ^
Ref. http://mattberseth.com/blog/2008/10/itunes_data_grid_skin.html?source=feed
'.NET > ASP.NET' 카테고리의 다른 글
| ASP.NET 2.0 AJAX - UpdateProgress (0) | 2009/10/11 |
|---|---|
| A .NET library for OpenFlashChart control (0) | 2009/03/29 |
| iTunes Data Grid Skin for ASP.NET GridView, ListView Control (0) | 2009/02/02 |
| Apache Mod_Rewrite use as URL_Rewrite in iis 7 (0) | 2009/01/21 |
| ASP.NET on Ruby on Rails (0) | 2008/03/14 |
| ASP.NET 503 서버 사용량이 많습니다. (0) | 2007/11/02 |
웹 개발을 하다보면 상당히 자주 사용하게 되는 것이
Cache를 어떻게 컨트롤할 지 결정하는 것이다.
이는 HTTP 헤더를 조작해야하는 작업이기 때문에 HTTP 헤더를 찾아보는 일이 많다.
이런 부분을 정리해둔 페이지가 있다.
위 링크를 활용하도록..
'Program' 카테고리의 다른 글
| UML 설계를 위한 첫걸음 (0) | 2007/08/16 |
|---|---|
| Tier와 Layer에 관한 이해 (0) | 2007/08/16 |
| HTTP Header Cache Control (0) | 2007/08/14 |
| VS 2008 and .NET 3.5 Beta 2 Released (0) | 2007/08/01 |
| 우분투 파티션설정없이 윈도우에 설치하기 (0) | 2007/07/06 |
| 주민등록번호 유효성의 체크 로직 (2) | 2007/07/04 |
Prev




