我正在尝试启用和禁用Button
基于ListBox
. 如果选择了一个值,则应启用该按钮。
我正在尝试使用触发器,但它给了我一个错误
'目标名称无法识别'。
<UserControl x:Class="Qualification.View.QualificationView"
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"
Height="500" Width="500">
<Grid>
<Button Name="btnOpen" Command="Open" CommandParameter="{Binding ElementName=lstName, Path=SelectedValue}" Height="23" Width="100" Margin="259,325,141,152">Add Qualification</Button>
<Grid.CommandBindings x:Uid="key">
<CommandBinding Command="Open" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed"/>
</Grid.CommandBindings>
<Grid.Resources>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="eble">
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent}}" Value="True">
<Setter TargetName="btnOpen" Property="IsEnabled" Value="False"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Grid.Resources>
<Label Height="23" Width="100" Margin="17,35,383,442" RenderTransformOrigin="0.48,-3.217">Search</Label>
<TextBox Name="txtSearch" Text="{Binding Qm.Search, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Height="23" Width="122" Margin="103,37,0,440" HorizontalAlignment="Left"></TextBox>
<Button Name="btnGo" Height="22" Width="30" Margin="205,37,265,441" RenderTransformOrigin="0.633,-1.318" Click="Button_Click_1">Go</Button>
<ListBox Name="lstName" ItemsSource="{Binding DocList}" Width="218" Margin="17,82,265,152">
</ListBox>
<!--<Button Command="{Binding AddQual}" CommandParameter="{Binding ElementName=lstName, Path=SelectedValue}" Height="23" Width="100" Margin="259,325,141,152">Add Qualification</Button>-->
</Grid>
</UserControl>