Presentation is loading. Please wait.

Presentation is loading. Please wait.

Сергей Пугачёв Microsoft Silverlight 5, XAML и связывание данных.

Similar presentations


Presentation on theme: "Сергей Пугачёв Microsoft Silverlight 5, XAML и связывание данных."— Presentation transcript:

1

2 Сергей Пугачёв Microsoft MVP @spugachev Silverlight 5, XAML и связывание данных

3 Сделали то, что просили…

4 XAML и связывание данных ImplicitDataTemplates RelativeSource Ancestor Bindings Binding In Style Setters Markup Extensions Databinding Debugging DataContextChanged Event (Post Beta) UpdateSourceTrigger (Post Beta)

5 Implicit Data Templates

6 Шаблоны основаны на типе Учитывается иерархия наследования

7 Relative Source

8 <TextBlock Text="{Binding StateName}" Visibility="{Binding IsDropDownOpen, RelativeSource={RelativeSource FindAncestor AncestorType=ComboBox}, Converter={StaticResource BoolToVisibilityConverter} }"/>

9 Markup Extensions

10 public class MethodInvokeExtension : IMarkupExtension { // Properties Exposed in XAML as Intellisense Love public String Method { get; set; } // Invoked by the XAML Parser @ runtime public object ProvideValue(IServiceProvider serviceProvider) { <UserControl x:Class="AppointmentsView" xmlns:MyUtils="clr-namespace:TestApp;assembly=TestApp">... <ComboBox Name="appointmentsListBox" SelectionChanged="{MyUtils:MethodInvoke Method=OnAppointmentChanged}"

11 Binding Style Setters

12 Создайте класс для представления значений Создайте экземпляр класса в ресурсах Используйте связывание данных в стилях <Setter Property="Foreground" Value="{Binding ForegroundColor, Source={StaticResource MyAppStyles}}"

13 DataContextChanged this.DataContextChanged += View_DataContextChanged; … void View_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { INotifyPropertyChanged customer; customer = e.OldValue as INotifyPropertyChanged; if (customer != null) customer.PropertyChanged -= customer_PropertyChanged; customer = e.NewValue as INotifyPropertyChanged; if (customer != null) customer.PropertyChanged += customer_PropertyChanged; }

14 UpdateSourceTrigger <TextBox Name="vinTextBox" Text="{Binding SelectedClaim.InsuredVIN, Mode=TwoWay}" UpdateSourceTrigger=PropertyChanged}"

15 XAML и связывание данных ImplicitDataTemplates RelativeSource Ancestor Bindings Binding In Style Setters Markup Extensions Databinding Debugging DataContextChanged Event (Post Beta) UpdateSourceTrigger (Post Beta)

16 Сергей Пугачёв Microsoft MVP @spugachev Silverlight 5, XAML и DataBinding

17


Download ppt "Сергей Пугачёв Microsoft Silverlight 5, XAML и связывание данных."

Similar presentations


Ads by Google