Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑这样的 XAML 片段:
<Grid> <Button x:Name="myButton"/> <m:MyControl Button="myButton"/> </Grid>
当然,这是行不通的。但我需要将名为“myButton”的 Button 控件实例作为值传递给另一个控件的Button属性。我也试过了,{StaticResource myButton}但它没有告诉我找不到资源。
Button
{StaticResource myButton}
什么是正确的 XAML 语法?
如果MyControl.Button是 DependencyProperty 你可以这样做
MyControl.Button
<m:MyControl Button="{Binding ElementName=myButton}" />