开发者

wpf c# check exist object in a grid

Hi every one i have a question

if there is a grid built by xaml, and in that grid there are many object created prgrammically by c#.

how to accsess that objects or know there are objects in that grid.

for example. in my grid first is empty, but after i click the button out site of the grid, that create some object like textblock and listbox. nah I have one other button to check and listing what object in that grid. this the xaml code :

<Grid x:Name="LayoutRoot">
        <TabControl Margin="0,0,0,141">
            <TabItem Header="TabItem">
                <Grid Background="#FFE5E5E5"/>
            </TabItem>
        </TabControl>
        <Button Content="Create Object" HorizontalAlignment="Left" Margin="87,0,0,54.04" VerticalAlignment="Bottom" Width="105"/>
        <Button Content="check object" HorizontalAlignment="Right" Margin="0,0,237,54.04" VerticalAlignment="Bottom" Width="75"/>
        <ListBox HorizontalAlignment="Right" Height="82" Margin="0,0,100,21" VerticalAlignment="Bottom" Width="101"/开发者_C百科>
    </Grid>

please help me


This may not be the easiest thing to do, but it's been written already so it's up to you to understand how it works and use it: Linq to Visual Tree
http://www.scottlogic.co.uk/blog/colin/2010/03/linq-to-visual-tree/
It helped me in a project I was working on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜