14 Results for '2009/05'
- 2009/05/22 VS2008, VS10, Silverlight 2, 3 함께 살기
- 2009/05/21 소니! VAIO 시리즈에 Intel-VT를 허하라!
- 2009/05/21 My Visual Studio 2010 machine (2)
- 2009/05/21 내가 굳이 Intel-VT를 통해 Windows 7의 XP Mode를 쓰고 싶은 이유 (6)
- 2009/05/17 DTFE2009 훈스닷넷 1세션 실버라이트 3 발표 자료 (3)
- 2009/05/14 마이크로소프트가 감시하고 있는 나의 모에... (4)
- 2009/05/13 DTFE2009 훈스닷넷 UX 세미나 - 실버라이트 3 가지고 놀기 예고편
- 2009/05/11 How about if DependencyObject could be a DataBinding target?
- 2009/05/09 Behaviors in Silverlight 2
- 2009/05/05 제1회 DevDcc 실버라이트3 발표자료 (3)
- 2009/05/04 Windows 7과 Virtualization 기술, 아직 갈 길이 멀지도... (6)
- 2009/05/04 Windows 7 RC 한국어 버전 좋네요 >_< (11)
- 2009/05/01 쒧!! SONY VAIO 저주나 받아라. (2)
- 2009/05/01 두근두근x7 [Updated] (8)
How about if DependencyObject could be a DataBinding target?
Programming/Silverlight 2009/05/11 11:17The Binding object only can take DependencyProperty on the FrameworkElement as a binding target in Silverlight. ‘Course, all of methods and properties related to DataBinding is on the FrameworkElement. DataBinding model might be designed to bind a source data to target ‘UI Element’ at the first time, I guess. It’s reasonable, and it looks like flawless. Just Before Behaviors feature was added to Silverlight.
Oneday, I created a simple Silverlight 3 application to explain Behaviors for my coworkers with Silverlight 3. Me and my coworkers were quite familiar with DataBinding through expierence of Silverlight 2, so I wanted to show them a demo with DataBinding.
The behavior what I created was very simple, you might already know ‘ShowMessageBoxAction’ if you tried Silverlight 3 Behaviors. Here’s the code:
public class ShowMessageBoxAction : TriggerAction<DependencyObject>
{
public
string Message { get;
set; }
{
MessageBox.Show(Message);
}
}
Yes it was a triggered action which shows MessageBox when Click event raised on Button. Nothing special, isn’t it? And then I wanted to mix it up DataBinding like:
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<local:ShowMessageBoxAction Message="{Binding Description}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
If you are a developer who is familiar with DatatBinding, you might be aware of my mistake and it would never work. As I mentioned above, a target of DataBinding must be a DependencyProperty on FrameworkElement. I think I got out of my mind at that time. It’s absolutely my mistake because all the Triggers and Behaviors were not FrameworkElement so these were not parts of VisualTree.
However, was that approach bad or evil? Well, I don’t think so. Because it looks like natural. I mean, when we write some XAML codes, It’s not easy to be aware of whether an element(tag) is a FrameworkElement or just other AttachedProperty. And it’s almost impossible to explain it reasonably for designers. Imagine that how designers add some behaviors to an element by using Expression Blend, Behaviors will shown on ‘Object Tree Panel’, not a just Property Panel. Who could know it’s impossible to use DataBinding untill opened a property panel of a Behavior and realize that DataBinding property was disabled.
What do I want to say? Well, I’m understand why Behaviors can’t be binded using DataBinding. However I think DataBinding makes work easy and efficeint, so how about if DataBinding could reach through any DependencyObject or AttachedProperty element?
Because, Silverlight 2 also can reference to Microsoft.Expression.Interactivity Assembly which is from Blend 3 library, you can take many advantages of Behaviors model from Silverlight 3 in Silverlight 2 as well. Yes, you can write Behaviors code without version dependency, and it can be referenced by both of Silverlight 2 and 3.
When I found that possibility, I was excited. As you know, Behaviors model brings you a great functionality which might reduce ‘bording-coding’ dramatically. All you have to do is that just copy-paste XAML from Blend 3, absolutely better than Blend 2, And even no code-behind!
I'm going to show you how to make a simple Silverlight 2 application using a simple trigger-action behavior. Create a new Silverlight project, and follow next steps.
Step 1. Referece a Microsoft.Expression.Interactivity Assembly.
Simply, copy a Microsoft.Expression.Interactivity Assembly to any folder to reference from your application. Usually, you can find it C:\Program Files\Microsoft Expression\Blend 3 Preview\Libraries\Silverlight folder if you installed Blend 3 Preview.
Notice that you must rename the assembly file, because Blend 2 can’t recongnize the name contains ‘Microsoft.Expression’. I don’t know why Blend 2 blocks specific assembly names like that. So just rename it say, Interactivy.dll or something. In this example, I renamed Microsoft.Expression.Interactivity.dll to Interactivity.dll.
After you reference the assembly, you might be encountered an error follow:
It makes you blind in Visual Studio. Don’t panic. :) It’s just a bug in Visual Studio Designer which already known. However Blend 2 will display it fine, if there was no other errors. Check this out further information.
Step 2. Create a simple trigger-action behavior.
Now, add a class say, ShowMessageBoxAction. It’ll show message box when trigger event raised on associated object.
public class ShowMessageBoxAction : TriggerAction< Dependencyobject>
{
#region Message
///
/// Gets or sets the Message possible Value of the string object.
///
public string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
///
/// Identifies the Message dependency property.
///
public static readonly DependencyProperty MessageProperty =
DependencyProperty.Register(
"Message",
typeof(string),
typeof(ShowMessageBoxAction),
new PropertyMetadata("Message")
);
#endregion Message
protected override void Invoke(object parameter)
{
MessageBox.Show(Message);
}
}
It has a property which you want to show up, and it ovverides Invoke method which is called when trigger event raised.
Step 3. Add a button with trigger.
Make some UI to check trigger performs well, follow:
<UserControl
x:Class="SL2Behaviors.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:Microsoft.Expression.Interactivity;assembly=Microsoft.Expression.Interactivity"
xmlns:local="clr-namespace:SL2Behaviors"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Button Content="Click
Me">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<local:ShowMessageBoxAction Message="Hello
Behaviors in Silverlight 2!" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</UserControl>
Step 4. Build & run!
How is it? It works fine like Silverlight 3 does. Also you can use other Behaviors like this as well. Try it after these steps. Yes, now you can use Behaviors in your Silverlight 2 applications.
Here is source code for above. It'll be more helpful rather than my poor English. :)
제 메인 PC의 개발 환경이 실버라이트 2로 되어 있어서 자료 정리에 시간이 많이 걸렸네요. 여튼 4월 18일 건국대 새천년 기념관에서 개최된 제 1회 DevDcc 행사에서 발표했던 “실버라이트 3의 등장과 디자인-개발 패러다임의 변화”의 PPT와 데모에요.
- (다운로드>) 슬라이드 – 달걀을 부탁해(^^)
- (다운로드>) 데모1 카드 뒤집기 게임 – 이은아님
- (다운로드>) 데모2 데이터 바인딩에 기반한 디자인 컨셉 – 장미연님
- (다운로드>) 데모3 물리엔진 비헤이비어를 활용한 에어하키 게임 – 김선구님
데모1에서는 디자이너 이은아님과 함께 처음 실버라이트를 접한 디자이너와 어느 정도 실버라이트 개발에 익숙해진 개발자가 겪을 수 있는 문제점을 다뤄봤어요. 디자이너와 개발자가 서로의 작업을 이해하고 도와주는 것이 역시 유일한 답이겠죠. 또 데모에는 남성 개발자들의 압도적인 지지를 받고 있는 *소녀시대*의 gee 영상으로 카드를 만들어 봤는데요, 아마 데모보다 이쪽에 더 관심 있는 분들이 많지 않을까 하네요 ㅎㅎ.
또한 데모1에서 자세한 설명은 하지 않았지만 Perspective 3D와 데이터 바인딩 그리고 WrapPanel등 실버라이트 3에서 새로 추가되거나 강화된 기능들을 적극적으로 활용하여 만들었으니 어느 정도 참고가 될 거에요.
데모 2에서는 디자이너 장미연님과 함께 했는데요, 장미연님은 현업에서 WPF 프로젝트를 수행하고 있고 개발과 디자인의 중간영역에서 디자이너가 어떤 역할을 해야 하는지에 대해 많은 경험을 가지고 계시죠. 또한 프로젝트 특성상 데이터를 다루는 일이 많은데요, 이 데모를 통해 실버라이트 3 그리고 블렌드 3에서 강화된 데이터 관련 기능을 어떻게 활용하는지 제시하고 있어요.
데모 2에서 개발자는 데이터 원본 생성과 패널 및 컨트롤 코드를 작성하는 임무를 맡고 디자이너는 그 데이터와 컨트롤들을 활용하여 자유롭게 디자인 할 수 있죠. 데모에서 최종적으로는 기존의 딱딱했던 사각형의 리스트박스에서 벗어나 애니메이션 효과와 함께 원형으로 배치되는 패널을 사용하여 데이터를 표시하고 있어요.
데모 3에서는 디자이너 김선구님과 함께 실버라이트 3에서 추가된 가장 강력한 기능 중 하나인 비헤이비어Behaviors에 대해 알아봤는데요, Behaviors는 크게 트리거Trigger & 액션Action과 비헤이비어Behavior로 나눌 수 있어요. Trigger&Action은 어떤 오브젝트에서 이벤트가 발생했을 때 특정 동작을 수행하는 것을 말하고 Behavior는 어떤 오브젝트가 가지는 그 외의 모든 행동 특성을 의미해요. Behaviors는 개발자에게 오브젝트의 행동을 모듈 단위로 설계하도록 도와주고 디자이너에게는 이 Behaviors를 사용하여 개발자의 도움 없이도 멋진 인터랙션을 가지는 애플리케이션을 디자인 할 수 있어요.
데모 3에서는 Behaviors의 활용을 극대화 하여 심지어 물리엔진 조차도 아주 간단하게 사용할 수 있는 방법을 제시하는데요, 저는 Behaviors의 개념이 앞으로 애플리케이션의 개발 패러다임을 확 바꿀 수 있다고 확신해요.
발표 자료가 이미지 중심으로 이루어져 있어서 자세한 설명은 동영상으로 보는 게 좋을 텐데요, 아쉽게도 아직 동영상 자료의 인코딩과 편집이 덜 끝났어요. 동영상이 업데이트 되면 블로그에 업데이트 할게요.
다시 한번 DevDcc 행사에 참가해주신 여러분께 감사 드립니다. ^^/
알려진 바와 같이 Windows 7은 XP MODE를 지원하죠. 바로 새로 나온 Windows Virtual PC를 통해 Windows 7에서 XP를 함께 사용할 수 있는 건데요, 자세한 내용은 꼬알라의 하얀집, 백승주 과장님께서 잘 정리해 주셨죠. Windows Virtual PC – Windows XP Mode for Windows 7을 참고하세요.
그런데 이렇게 멋진 기능은 반드시 PC가 Virtualization을 지원해야 해요. 즉, Intel 플랫폼의 경우 Intel-VT, AMD 플랫폼의 경우는 AMD-V라는 기능을 CPU뿐만 아니라 메인보드의 BIOS에서도 지원을 해야 하죠.
문제는 이 Virtualization 기술이 발표 된지 상당히 오래되었지만 아직 ‘대다수’의 신규 PC 플랫폼에 적용된다고 말하긴 어렵다는 점이에요. AMD-V의 경우 일반 판매되는 대부분의 플랫폼이 AMD-V 기술을 사용할 수 있게 되어 있지만 Intel의 경우 유독 저가형에는 VT기술이 비활성화 되어 나온 경우가 많아요. 국내 최대의 PC 구매 정보 사이트인 다나와에서 Intel 쪽 상황을 볼까요?
다나와의 4월 CPU 인기순위를 참고하면 Intel CPU중에서 가장 많이 팔리는 순서는 Core2Duo E5200 –> E7400 –> E8400 –> Core2Quad Q8200 이에요. 이 중에서 E8400을 제외한 3개의 CPU가 Intel-VT 기술이 비활성화 되어 있죠. 그런데 다나와 상품 소개란에는 아주 혼란스럽게 된다고 표기된 곳도 있고 아닌 곳도 있어요. 저도 대충 확인하고 E5200을 구매했다가 눈물 좀 흘렸죠.
그나마 인텔은 6월 12일 이후로 Intel-VT 기술을 새로 발매될 revision의 E5300이상의 모델에 활성화 하겠다고 하는군요. 물론 기존의 CPU에는 해당사항이 없는 얘기고요. 당분간 유저의 혼란은 더 커질 거에요. 똑같은 CPU인데 revision에 따라 VT가 지원되고 안되고 –_-. 뭐 인텔의 상술(?)가지고 왈가왈부하고 싶지는 않아요. 그렇지만 한 가지 분명한 건 현재 매우 높은 시장 점유율을 차지하고 있는 인텔 CPU들이 Intel-VT를 지원하지 않는 다는 사실이죠. 이 점을 마이크로소프트에서는 분명히 인지하길 바라고, ‘최근 출시되는 대부분의 플랫폼이 Virtualization을 지원한다’는 판단은 분명히 잘못되었다고 말하고 싶어요. 적어도 일반 유저를 대상으로 한 시장에는 말이죠.
뭐, 한낱 조립 시장 따위로 전체 시장을 얘기할 수는 없겠죠? 그럼 대기업 브랜드 PC나 노트북 시장은 어떨까요? 저도 구체적인 자료는 없어서 단순히 다나와 인기(판매)순위를 참고해 보죠.
4월 현재 다나와의 브랜드 PC(대기업제 PC) 인기 순위에서 CPU만 살펴보면,
E5200, E7400, E7300, ATOM N230, E5200, Q8300, Q8200, (Apple), Q8300, E7400이에요.
네, 약간 충격적(?)인 결과인데요, 저 중에서 Apple iMAC을 제외한 모든 모델에서 Intel-VT를 지원하지 않아요. 다음 노트북 인기 순위를 볼까요?
(ATOM)N270, VIA U2250, N270, N270, N270, N270, N270, N280, AMD QL-62, T3200
아아… 이건 더 충격적인데요, 요즘 최고의 인기를 누리고 있는 아톰 프로세서를 사용한 소위 ‘넷북’의 인기가 하늘을 찌르네요. 말 할 것도 없이 아톰 프로세서는 가상화 기술을 지원하지 않고요.이 중에서 가상화를 지원하는 건 AMD QL-62뿐이에요.
이 결과만 놓고 보면 적어도 다나와를 통해 판매된 상위 80%의 제품은 PC와 노트북을 가리지 않고 가상화를 지원하지 않는다고 말 할 수 있죠. Windows 7이 출시되어도 과연 얼마나 많은 유저가 Virtualization을 활용한 XP Mode의 혜택을 누릴 수 있을까요? 혹시 XP Mode를 적극적으로 마케팅한다면 그 뒤에 있을 혼란은 엄청날거라고 예상할 수 있어요.
참고로 전체 시장에 비하면 큰 부분은 아니겠지만 무시할 수 없는 부분이 있는데요, 특히 소니의 VAIO 노트북은 거의 전 모델에 걸쳐 Intel-VT를 지원하지 않아요. 이건 대놓고 지원하지 않는다고 스펙에 명시되어 있죠. 심지어 CPU가 지원하더라도 노트북 메인보드의 BIOS에서 이것을 비활성화 해놓은데다가 활성화 하는 옵션 조차 없어요.
사실 가상화를 통한 XP Mode 지원이 이렇게까지 신경 쓰이는 이유는 그 빌어먹을 국내 웹사이트들의 ActiveX 남발 때문이죠. IE8 호환성 모드 어쩌고 해 봤자 Vista나 Windows 7에서는 죽어도 설치 안 되는 ActiveX도 있고요 백보 양보해도 일단 설치가 너무너무 귀찮고 사용도 귀찮을 뿐더러 ActiveX 막 설치하다 보면 시스템마저 불안정해지죠. 이런 상황에서 XP 모드는 정말이지 꼭 필요한 기능이에요. 전 제 Windows 7을 N-Protect와 같은 쓰레기 프로그램으로 더럽히고 싶지 않거든요.
결론이 뭐냐고요? Windows 7의 XP Mode가 Virtualization 기술 없이도 동작되길 바라는 거죠. 설사 성능상의 불이익을 감수하고서라도 말이죠. 만약 기술적으로 불가능하다면 하다못해 Virtual PC로 XP를 조금이나마 쉽고 빠르게 띄울 수 있는 방법을 제공해줬으면 하고요.
+ 지금 MSDN 수시로 다운되고 난리가 아님 =_=
+ 현재 제공되는 RC용 언어팩은 영어, 프랑스어, 독일어, 일본어, 스페인어 뿐...
Behaviors in Silverlight 2.zip