锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲精品91在线,亚洲一区二区五区,黄色小视频在线播放 http://www.aygfsteel.com/zxj8314/archive/2007/02/05/98100.htmlzilong zilong Mon, 05 Feb 2007 11:49:00 GMT http://www.aygfsteel.com/zxj8314/archive/2007/02/05/98100.html http://www.aygfsteel.com/zxj8314/comments/98100.html http://www.aygfsteel.com/zxj8314/archive/2007/02/05/98100.html#Feedback 0 http://www.aygfsteel.com/zxj8314/comments/commentRss/98100.html http://www.aygfsteel.com/zxj8314/services/trackbacks/98100.html http://www.beacosta.com/Archive/2005_09_01_bcosta_archive.html聽 聽聽1.緇戝畾鏂瑰紡錛?br />聽聽聽聽聽聽 1錛塖ource/Data Context錛?br />聽聽聽聽聽聽聽聽聽聽聽聽<Window.Resources> 聽聽聽聽聽聽聽聽聽聽<local:GreekGod Name="Zeus" Description="Supreme God of聽聽聽聽the聽聽聽聽Olympians"聽聽聽聽聽聽聽RomanName="Jupiter" x:Key="zeus"/> 聽聽聽聽<local:GreekGod Name="Poseidon" Description="God of the sea, earthquakes and horses"聽聽聽聽RomanName="Neptune" x:Key="poseidon"/> </Window.Resources> <StackPanel DataContext="{StaticResource poseidon}"> 聽聽聽聽<TextBlock TextContent="{Binding Source={StaticResource zeus}, Path=Name}"/> 聽聽聽聽<TextBlock TextContent="{Binding Path=Description}"/> 聽聽聽聽<TextBlock TextContent="{Binding Path=RomanName}"/> </StackPanel> Data Context鍏佽鍏冪礌浠庡畠鐨勭埗鍏冪礌緇ф壙鏁版嵁緇戝畾鐨勬暟鎹簮銆?br />Source 鏍囪鏄懼紡鎸囧畾鏁版嵁婧愩?br />涓鑸儏鍐典笅錛岀粦瀹氭簮瀵硅薄涓涓睘鎬ф椂鐢―ata Context錛岀粦瀹氭簮瀵硅薄涓崟涓睘鎬ф椂鐢?span>Source銆?/span> 聽鍦ㄧ粦瀹氭椂聽Source 鍜孌ata Context鏁堟灉涓鏍鳳紝鍙槸Source鐨勪紭鍏堢駭姣?/span>Data Context聽楂樸偮犲鏋滅粦瀹氬璞℃槸涓涓獂ml錛屽垯{Binding}涓睘鎬х敤xpath鏉ユ寚瀹氬簲璇ヤ嬌鐢?XML 鏂囨。涓殑鍝釜闆嗗悎鏉ュ~鍏呫偮犅犅?br />2錛塃lementName錛?br />3錛?font face="Verdana">RelativeSource錛?br />2.{binding} 聽聽聽bingding鏈塻ource鍜宲ath灞炴э紝鍏朵腑source灞炴ф寚瀹氱粦瀹氱殑鍏蜂綋鏁版嵁瀵硅薄錛宲ath鎸囧畾璇ュ璞$殑鐗瑰畾灞炴с傚綋閫昏緫鏍?wèi)涓湁Data Context錛屽彲浠ヤ笉鐢ㄨ瀹歜inding涓璼ource灞炴э紱褰揵inding涓病鏈夎瀹歱ath灞炴ц〃鏄庣粦瀹氭暣涓璞°?br /><Window.Resources> 聽聽聽聽<local:GreekGod Name="Zeus" Description="Supreme God of the Olympians" RomanName="Jupiter" x:Key="zeus"/> </Window.Resources> <Border DataContext="{StaticResource zeus}"> 聽聽聽聽<ContentControl Content="{Binding}"/> </Border> 聽聽 濡傛灉瑕佸皢鏌愪竴鍏冪礌涓庡璞$殑澶氫釜灞炴х粦瀹氭椂錛?/font>ContentControl 涓嶇煡閬撳浣旼reekGod 鐨勪俊鎭傝繖鏃惰鐢ㄥ埌DataTemplate錛屽畠鐨勪綔鐢ㄦ槸鎸囧畾鏁版嵁鏄劇ず褰㈠紡銆?br />聽聽聽<Window.Resources> 聽聽聽聽<local:GreekGod Name="Zeus" Description="Supreme God of the Olympians" RomanName="Jupiter" x:Key="zeus"/> 聽聽聽聽<DataTemplate x:Key="contentTemplate"> 聽聽聽聽聽聽聽聽<DockPanel> 聽聽聽聽聽聽聽聽聽聽聽聽<TextBlock Foreground="RoyalBlue" TextContent="{Binding Path=Name}" /> 聽聽聽聽聽聽聽聽聽聽聽聽<TextBlock TextContent=":" Margin="0,0,5,0" /> 聽聽聽聽聽聽聽聽聽聽聽聽<TextBlock Foreground="Silver" TextContent="{Binding Path=Description}" /> 聽聽聽聽聽聽聽聽</DockPanel> 聽聽聽聽</DataTemplate> </Window.Resources> <Border DataContext="{StaticResource zeus}"> 聽聽聽聽<ContentControl Content="{Binding}" ContentTemplate="{StaticResource contentTemplate}"/> </Border> 娉ㄦ剰錛?font face="Courier" color="#6666cc">DataTemplate涓殑{binding}娌℃湁source灞炴э紝榪欐槸鍥犱負(fù)鑷姩鍦板皢Data Context璁句負(fù)鏁版嵁瀵硅薄緇戝畾鏂瑰紡銆偮?/font> 3銆?font face="Courier" color="#6666cc">get ListItem from a data bound Listbox xaml: 聽聽聽 <Window.Resources> 聽聽聽聽<local:GreekGods x:Key="greekGods"/> 聽聽聽聽<DataTemplate x:Key="itemTemplate"> 聽聽聽聽聽聽聽聽<TextBlock Text="{Binding Path=Name}" /> 聽聽聽聽</DataTemplate> </Window.Resources> <ListBox ItemsSource="{StaticResource greekGods}" ItemTemplate="{StaticResource itemTemplate}" Name="listBox"/> listBox鐨処temSource鏈変竴涓?font face="Verdana">IEnumerable鎺ュ彛錛屾槸浣犳兂瑕佹樉紺虹殑items鍒楄〃 Itemtemplate灞炴ф寚瀹氱敤鏉ユ帶鍒舵暟鎹樉紺虹殑datatemplate銆?br /> c#:GreekGod greekGod = (GreekGod)(listBox.Items[0]);//緇戝畾鐨勬暟鎹璞★紱ListBoxItem lbi1 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromIndex(0));//榪斿洖ListBoxItem錛?/font>ListBoxItem lbi2 = (ListBoxItem)(listBox.ItemContainerGenerator.ContainerFromIndex(listBox.Items.CurrentItem)); 涓轟簡淇濊瘉閫変腑欏逛笌褰撳墠欏瑰悓姝ワ紝璁懼畾 IsSynchronizedWithCurrentItem= "true". 4.get a ComboBoxItem from a data bound ComboBox 涓巐istbox鐩鎬技錛?br /> Window.Resources> 聽聽聽聽<local:GreekGods x:Key="greekGods"/> 聽聽聽聽<DataTemplate x:Key="itemTemplate"> 聽聽聽聽聽聽聽聽<TextBlock Text="{Binding Path=Name}" /> 聽聽聽聽</DataTemplate> </Window.Resources> <ComboBox ItemsSource="{StaticResource greekGods}" ItemTemplate="{StaticResource itemTemplate}" Width="200" Name="comboBox"/> c#:GreekGod greekGod = (GreekGod)(comboBox.Items[0]); comboBox.IsDropDownOpen = true; ComboBoxItem cbi1 = (ComboBoxItem)(comboBox.ItemContainerGenerator.ContainerFromIndex(0)); ComboBoxItem cbi2 = (ComboBoxItem)(comboBox.ItemContainerGenerator.ContainerFromItem(comboBox.Items.CurrentItem)); comboBox.IsDropDownOpen = false; 娉ㄦ剰錛?br />璋冪敤ContainerFromIndex涔嬪墠瑕佸厛鎵撳紑緇勫悎妗嗐?font face="Courier" color="#6666cc">comboBox.IsDropDownOpen = true; ]]>
主站蜘蛛池模板:
临湘市 |
垫江县 |
沙洋县 |
额尔古纳市 |
改则县 |
红河县 |
宝丰县 |
阿勒泰市 |
金坛市 |
济阳县 |
大邑县 |
山西省 |
烟台市 |
湖北省 |
台北县 |
沈阳市 |
阿拉善右旗 |
蒙城县 |
庄河市 |
乌苏市 |
阜康市 |
洪雅县 |
新野县 |
东安县 |
喀喇沁旗 |
河西区 |
潮安县 |
西青区 |
仁寿县 |
岢岚县 |
健康 |
海南省 |
陵川县 |
名山县 |
阿鲁科尔沁旗 |
贵南县 |
巴林左旗 |
监利县 |
邹平县 |
射洪县 |
施秉县 |