【发布时间】:2011-11-02 13:43:22
【问题描述】:
我有一个这样的用户控件:
<UserControl x:Class="MySample.customtextbox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="20" d:DesignWidth="300">
<Grid>
<TextBox x:Name="Ytextbox" Background="Yellow"/>
</Grid>
</UserControl>
我想在 mvvm 模式中使用我的控件...我希望我可以将我的视图模型中的属性绑定到 Ytextbox 文本属性
<CT:customtextbox ?(Ytextbox)Text ="{binding mypropertyinviewmodel}"/>
...我该怎么做?
【问题讨论】:
标签: c# wpf mvvm user-controls