<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">http://www.bcmeng.com/databinding/</span>
记录一下:
1 网页跳转
this. Frame.Navigate(typeof(className));
this. Frame.Navigate(typeof(className), parameter);
2. Binding in DataContext, ItemsSource
{Binding} - bind to current data, which is defined by parent;
{Binding property} - bind to the property, which is one of attributes of parent's binds or which is one of current datacontext;
<ListViewItemsSource="{Binding}"IsItemClickEnabled="True"ItemClick="GroupSection_ItemClick"ContinuumNavigationTransitionInfo.ExitElementContainer="True"><ListView.ItemTemplate><DataTemplate><StackPanel Margin="0,0,0,27.5"><TextBlock Text="{Binding Title}" Style="{ThemeResource ListViewItemTextBlockStyle}" /></StackPanel></DataTemplate></ListView.ItemTemplate></ListView>
{Binding MyObject.MyProperty} - bind to the specific property of MyObject
mc:Ignorable="d"DataContext="{Binding DefaultViewModel.Item, RelativeSource={RelativeSource Self}}"d:DataContext="{Binding Groups[0].Items[0], Source={d:DesignData Source=/DataModel/SampleData.json, Type=data:SampleDataSource}}"
{Binding ElementName=MyTextBox, Path=Text} - bind to the datacontext, which is another control with ID or Name of MyTextBox, binding to the Text property of MyTextBox
{Binding MyObject, RelativeSource={RelativeSource Self}} - bind to MyObject, which is a partical class of this page;
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
3.
DefaultViewModel <-> Page.DataContext
has |
groups[0] <-> HubSection.DataContext
has |
Items <-> GridView.ItemsSource
has |
ID/Name/... <-> GridView.ItemTemplate
4. One of the feature utility of binding is MVVM.
...