第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

WPF數(shù)據(jù)綁定:如何訪問(wèn)“父”數(shù)據(jù)上下文?

WPF數(shù)據(jù)綁定:如何訪問(wèn)“父”數(shù)據(jù)上下文?

WPF數(shù)據(jù)綁定:如何訪問(wèn)“父”數(shù)據(jù)上下文?我有一個(gè)窗口中包含的列表(見(jiàn)下文)。窗口DataContext有兩個(gè)屬性,Items和AllowItemCommand。如何獲取針對(duì)窗口的屬性需要解析Hyperlink的Command屬性DataContext?<ListView ItemsSource="{Binding Items}">   <ListView.View>     <GridView>       <GridViewColumn Header="Action">         <GridViewColumn.CellTemplate>           <DataTemplate>             <StackPanel>               <TextBlock>                 <!-- this binding is not working -->                 <Hyperlink Command="{Binding AllowItemCommand}"                            CommandParameter="{Binding .}">                     <TextBlock Text="Allow" />                 </Hyperlink>               </TextBlock>             </StackPanel>           </DataTemplate>         </GridViewColumn.CellTemplate>       </GridViewColumn>     </GridView>   </ListView.View></ListView>
查看完整描述

3 回答

?
BIG陽(yáng)

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

你可以嘗試這樣的事情:

...Binding="{Binding RelativeSource={RelativeSource FindAncestor, 
AncestorType={x:Type Window}}, Path=DataContext.AllowItemCommand}" ...


查看完整回答
反對(duì) 回復(fù) 2019-08-06
?
慕村225694

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊

這也有效:

<Hyperlink Command="{Binding RelativeSource={RelativeSource AncestorType=ItemsControl},
                             Path=DataContext.AllowItemCommand}" />

ListView將繼承其DataContextWindow,所以它的使用在這一點(diǎn)上,太。
并且,因?yàn)?code>ListView,就像類似的控件(例如Gridview,ListBox等等)是其子類ItemsControl,Binding對(duì)于這樣的控件將完美地工作。


查看完整回答
反對(duì) 回復(fù) 2019-08-06
?
臨摹微笑

TA貢獻(xiàn)1982條經(jīng)驗(yàn) 獲得超2個(gè)贊

這也適用于Silverlight 5(也許更早,但我還沒(méi)有測(cè)試過(guò))。我使用了這樣的相對(duì)來(lái)源,它工作得很好。

RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=telerik:RadGridView}"


查看完整回答
反對(duì) 回復(fù) 2019-08-06
  • 3 回答
  • 0 關(guān)注
  • 1385 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)