[英]Access controls not properties in XAML User Control
我已经知道如何编写用户控件以及如何使用XAML用户控件中的依赖项属性访问内部控件属性。
我的问题是,如何在用户控件内部访问控件本身。 例如,
用户控件:TbCanvas.xaml
<UserControl
x:Class="Sample.Control.TbCanvas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
x:Name="root">
<Grid>
<Image x:Name="imageMain" />
</Grid>
</UserControl>
我想在具有如下用户控件的某些Page
中使用它。
SomePage.xaml.cs
this.tbCanvas.imageMain.Source = "some_path";
当然,可以将Source
作为具有Binding
Dependency Property
给出,但是我有时需要访问内部控件,因为控件的每个属性都不是完全可绑定的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.