WPF 3.5 の新機能 川 裕幸 UX エバンジェリスト デベロッパー & プラットフォーム統括本部 マイクロソフト株式会社
WPF 3.5?.NET Framework 3.5 に含まれる WPF SP1 + 新しいアセンブリ (System.Core.dll など ) Linq は System.Core.dll に含まれる.NET Framework 3.0 SP1 に含まれる WPF Windows Server 2008 Windows Vista SP1 ただし Linq バインディングを使うときは注意 詳しくは Visual Studio 2008 ドキュメント バージョン情報を参照
互換性 WPF 3.0 でビルドしたアプリは WPF3.5 上 (ex. Vista SP1) で動作 WPF 3.5 でビルドしたアプリは WPF3.0 上では動作しない.NET Framework 3.5 のインストールが必要 新機能を使っていなければ動作するかもしれない... 新しいスキーマ http://schemas.microsoft.com/netfx/2007/xaml/presentation これまでのスキーマも有効
アプリケーションモデル XBAP Firefox HTTP Cookie 部分信頼 WCF サービス Add-In サポート dll を実 時に動的に統合できる
部分信頼 WCF サービス ASP.NET 中間アクセス権で動作するサーバーアプリで アプリで WCF Service Model を使って基本 HTTP サービスを作成インターネットゾーンアクセス権で動作するクライアントアプリ (ex. XBAP) は WCF プロキシ経由で HTTP サービスを利 部分信頼フルサポート BasicHttpBinding, WebHttpBinding トランスポートトセキュリティモードのみサポート WSHttpBinding 部分信頼 サポート NetTcpBinding, NetNamedPipeBinding, NetMsmgBinding
Add-In WPF は Add-In を使って UI を表 できる UI を返す Add-In ロードする条件によって変化する UI UI である Add-In 同じ UI を表 ex. カラーピッカー FrameworkElement を継承したクラス 順 Shape, Control, User Control, Panel パイプラインの作成契約の宣 Add-In は FrameworkElement を INativeHandleContract に変換して返す ( あるいは 分 を変換して渡す ) 返された ( あるいは渡された ) INativeHandleContract を FrameworkElement に変換ホストアプリは返された ( あるいは渡された ) FrameworkElement を表
データ ビジネスオブジェクト検証 IDataErrorInfo {Binding ValidatesOnDataErrors=true} Linq および Xlinq バインディングサポート Path=Element[content].Attribute[url].Value XML (DOM) バインディング性能改善 DataSet バインディング性能改善
データ デバッグの改善 バンディングトレース PresentationTraceSources.TraceLevel Low, Medium, High <Window x:class= SampleApplication.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xamlmicrosoft com/winfx/2006/xaml xmlns:diag= clr namespace:system.diagnostics;assembly=windowsbase > <Button Background= {Binding Path=ProductColor, diag:presentationtracesource.tracelevel=high /> ti T </Window> Binding の新しいプロパティ ValidatesOnExceptions ValidatesOnDataErrors
テキスト TextBox の IME サポート FrameworkTextComposition に新しいプロパティ CompositionOffset CompositionLenght ResultOffset ResultLength IME で 中 TextInput, TextInputUpdate, TextInputStart イベントが発 するととき TextCompositionEventArgs.TextComposition ta T として使 RichTextBoxの改善 UIElement がインラインで可能 カスタム TextElement が可能
サウンド 応答 再 の新しいクラス SoundPlayerAction <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Page.Triggers> <EventTrigger RoutedEvent="Button.Click" SourceName="clickButton"> <EventTrigger.Actions> <SoundPlayerAction Source="media lowbat.wav"/> </EventTrigger.Actions> </EventTrigger> <EventTrigger RoutedEvent="Button.MouseEnter" SourceName="hoverButton"> <EventTrigger.Actions> <SoundPlayerAction Source="media tada.wav"/> </EventTrigger.Actions> </EventTrigger> </Page.Triggers> <StackPanel Width="200"> <Button Name="clickButton">Click to Play Sound</Button> <Button Name="hoverButton">Hover " to Play Sound</Button> </StackPanel> </Page>
パフォーマンス レイヤーウィンドウのハードウェア化
パフォーマンス レイヤーウィンドウのハードウェア化 KB938660 でも解決
3D System.Windows.Media.Media3D.Visual3D System.Windows.Media3D.ModelVisual3D System.Windows.UIElemt3D UIElement3D( 仮想 ) System.Windows.Media.Media3D.ContainerUIElemt3D System.Windows.Media.Media3D.ModelUIElement3D System.Windows.Media3D.Viewport2DVisual3D ContainerUIElement3D, t3d ModelUIElement3D フォーカス イベントをサポートするModelVisual3D OnModelUpdate, d InvalidateModel d l メソッドを持つ Viewport2DVisual3D ( 機能する )Visual が張れるModelVisual3D 3D 上のインタラクティブな 2Dコンテンツ GeneralTransform3D( 仮想 ) 新しい座標変換クラス GeneralTransform3DTo2D, GeneralTransform2DTo3D
UIElement3D UIElement と同等のイベントハンドリング 交差テスト コードを書く必要はもうない 内部階層のルーティングイベントも処理 レイアウト機能はない
UIElement3D その 1 Handling Events in 3-D DS Sample <ModelUIElement3D MouseDown= Cube1MouseDown > <ModelUIElement3D.Transform> <TranslateTransform3D OffsetZ= 1.5 /> </ModelUIElement3D.Transform> <ModelUIElement3D.Model> <GeometryModel3D Geometry="{StaticResource CubeMesh}"> <GeometryModel3D.Material> Material> <DiffuseMaterial x:name= cube1material Brush= Blue /> </GeometryModel3D.Material> </GeometryModel3D> </ModelUIElement3D.Model> </ModelUIElement3D> private void Cube1MouseDown(object sender, MouseButtonEventArgs e) { cube1material.brush = (cube1material.brush == Brushes.Blue Bl? Brushes.Red : Brushes.Blue); Bl }
UIElement3D その 2 OnModelUpdate, d InvalidateModel d l メソッドにより データバインディングを使った通知が可能に プロパティ変更による 変更が可能な UIElement3D 派 クラスが作成できる <Slider Width= 300 Maximum= 60 Minimum= 60 Margin= 10 Value= {Binding ElementName=MyCylinder, Path=Angle} /> <Viewport3D Width= 480 Height= 400 Margin= 10 > <Viewport3D.Camera> <PerspectiveCamera Position= 0,3,10 FieldOfView= 45 /> </Viewport3D.Camera> <local:cylinder l li x:name= MyCylinder /> <ModelVisual3D> <ModelVisual3D.Content> <DirectionalLight Color= White Direction= 0,0, 1 /> 0 </ModelVisual3D.Content> </ModelVisual3D> </Viewport3D>
UIElement3D その 2 protected override void OnUpdateModel() { GeometryModel3D model = new GeometryModel3D(); model.geometry = Tessellate(Angle); model.material = new DiffuseMaterial(Brushes.Blue); Model = model; } public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( Angle, typeof(double), typeof(cylinder), new PropertyMetadata(0.0, t t 0 AnglePropertyChanged)); private static void AnglePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Cylinder s = (Cylinder)d; s.invalidatemodel(); } public double Angle { get {return (double)getvalue(angleproperty);} set {SetValue(AngleProperty, value);} }
Viewport2DVisual3D Viewport3D 内でも Visual が使える Binding が利 できる イベントハンドラとコールバックが利 できる ただし Preview イベントハンドラを使うこと
Viewport2DVisual3D <Viewport2DVisual3D x:name="mymodel1 Geometry="{StaticResource ti mysquare}" > <Viewport2DVisual3D.Transform> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Angle="-45" Axis="0 1 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Viewport2DVisual3D.Transform> <Viewport2DVisual3D.Material> <DiffuseMaterial Brush="White" Viewport2DVisual3D.IsVisualHostMaterial="True"/> </Viewport2DVisual3D.Material> <StackPanel> <TextBox Name="myInput" Background="White" Width="100" Height="20"/> <TextBlock Name="myText" mytext Background="Red" Width="50" Height="50" Text="{Binding ElementName=myInput, Path=Text} /> <Button PreviewMouseLeftButtonDown="Button_MouseLeftButtonDown"> Change Color </Button> </StackPanel> </Viewport2DVisual3D>
GeneralTransform3D 3D 間 3D と 2D 間の座標変換 3Dジオメトリの点などを 2D 空間に座標変換したいとき便利 GeneralTransform3D Visual3D.TransformToAncestor(Visual3D) Visual3D.TransformToDescendant(Visual3D) GeneralTransform3DTo2D Visual3D.TransformToAncestor(Visual) GeneralTransform2DTo3D Visual.TransformToAncester(Visual3D) D e s c e n d a n t Canvas Viewport3D ModelVisual3D Parent ModelVisual3D Child A n c e s t o r
ご質問は?