我在另一个内部有一个自定义UserControl:
<Grid ....>
<Contentcontrol Name="ContentPresenter" />
<Button Content="NextButton" />
</Grid>
我将ContentPresentr
内容设置为具有一些TextBox
的自定义用户控件。我希望启用/禁用第一个按钮,具体取决于第二个用户控件中的TextBox
是否具有任何值。
这是我的尝试:
<UserControl ....>
<Contentcontrol Name="ContentPresenter" />
<Button Content="NextButton" >
<Button.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type view:UsersUcAddStep0}}, ElementName=TextBoxName}" Value="{x:Null}" />
</MultiDataTrigger.Conditions>
</MultiDataTrigger>
</Button.Triggers>
</Button>
</UserControl>
ContentControl.xaml(总结,太大了):
<UserControl x:Class="View.UsersUcAddStep0"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="AddUserInfo"
Loaded="UsersUcAddStep0_OnLoaded"
Unloaded="OnUnloaded">
<Grid VerticalAlignment="Center" >
<TextBox Grid.Column="3" Grid.Row="0" Name="TextBoxName"
Margin="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight,
Converter={StaticResource ArithmeticConverter}, ConverterParameter=Int32.Parse(values[0]) / 2.5}"
Style="{DynamicResource InnerTextBox}"
Validation.ErrorTemplate="{StaticResource ValidationErrorTemplate}"
LostFocus="TextBox_OnLostFocus"
PreviewKeyDown="TextBox_OnPreviewKeyDown"
model:TextBoxBehavior.SelectAllTextOnFocus="True">
<TextBox.Text>
<Binding Path="Name" Source="{StaticResource UserInformation}" UpdateSourceTrigger="LostFocus" >
<Binding.ValidationRules>
<DataErrorValidationRule ValidatesOnTargetUpdated="False" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</Grid>
</UserControl>
但它根本没有编译。有人知道如何进行这种绑定吗?