簡體   English   中英

如何從背后的代碼操縱擴展頭

[英]How manipulate expander header from code behind

我在XAML中有以下代碼:

  <Expander BorderBrush="DarkGray" Background="White" SourceUpdated="Expander_SourceUpdated" GotFocus="Expander_GotFocus">
                                                <Expander.Header>
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock Text="Grupo " VerticalAlignment ="Center"/>
                                                        <TextBlock x:Name="Tblockgrupo" Text="{Binding Name}" VerticalAlignment ="Center" GotFocus="TextBlock_GotFocus" />
                                                        <TextBlock Text="{Binding ItemCount}" VerticalAlignment ="Center"/>
                                                        <TextBlock Text=" Variable(s)" VerticalAlignment ="Center"/>
                                                    </StackPanel>
                                                </Expander.Header>
                                                <ItemsPresenter />
                                            </Expander>

我的問題是,當擴展器具有焦點時,如何從代碼隱藏(c#)中捕獲名稱為Tblockgroup的TextBlock文本。

我找到了解決方案

對象結果= Prueba.FindName(“ name”); if(結果是TextBlock){//如果找到Text元素,則執行以下操作。 TextBlock resultconvert =結果為TextBlock; MessageBox.Show(resultconvert.Text); }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM