Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to binding a property of its child?

$
0
0

Hi all,

the below code just be test code to bind its child property background, but it does not work. I just want to use RelativeSource way, but no by elementname. Since I would like to use it in datagrid, so here just a test. thanks.

 <Canvas>
            <StackPanel Height="200" Width="200" HorizontalAlignment="Left" Background="{Binding Path=Children[0].Background, RelativeSource={RelativeSource Self}}" Panel.ZIndex="1" Canvas.Left="-50">
                <StackPanel Height="50" Width="180" Background="Red" Panel.ZIndex="10" Margin="100,0,0,0" ></StackPanel>
            </StackPanel>
        </Canvas>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>