我无法访问名称“LeftButton”和“右键”来自 Listbox.triggers 的地方
<GroupBox BorderThickness="0" Grid.Row="1" Header="Members" Style="{StaticResource CenteredHeaderGroupBoxStyle}">
<GroupBox.HeaderTemplate>
<DataTemplate>
<Border>
<Grid HorizontalAlignment="Center">
<ToggleButton Name="LButton" Content="Members" Style="{StaticResource TabL}" />
<ToggleButton Name="RButton" Content="Groups" Style="{StaticResource TabR}" />
</Grid>
</Border>
</DataTemplate>
</GroupBox.HeaderTemplate>
<GroupItem>
<Border>
<ListBox Name="GroupMemberList" ItemsSource="{Binding Path=MembersoftheCase}">
<ListBox.Triggers>
<Trigger SourceName="LButton" Property="IsChecked" Value="True">
<Setter Property="ListBox.ItemsSource" Value="{Binding Path=MembersoftheCase}"/>
<Setter Property="ListBox.ItemTemplate" Value="{StaticResource MListTemplate}"/>
</Trigger>
<Trigger SourceName="RButton" Property="IsChecked" Value="True">
<Setter Property="ListBox.ItemsSource" Value="{Binding Path=GroupsoftheCase}"/>
<Setter Property="ListBox.ItemTemplate" Value="{StaticResource GListTemplate}"/>
</Trigger>
</ListBox.Triggers>
</ListBox>
</Border>
我在编译时遇到异常,由于此错误,设计器未加载
属性“SourceName”不代表“触发器”的有效目标,因为未找到名为“LButton”的元素。确保目标在使用它的任何 Setter、触发器或条件之前声明。
我还尝试将触发器放在按钮本身上,将 GroupmembersList 作为目标
,然后无法找到 TargetName
F1 F1
<GroupBox BorderThickness="0" Grid.Row="1" Header="Members" Style="{StaticResource CenteredHeaderGroupBoxStyle}">
<GroupBox.HeaderTemplate>
<DataTemplate>
<Border>
<Grid HorizontalAlignment="Center">
<ToggleButton Name="LButton" Content="Members" Style="{StaticResource TabL}" />
<ToggleButton Name="RButton" Content="Groups" Style="{StaticResource TabR}" />
</Grid>
</Border>
</DataTemplate>
</GroupBox.HeaderTemplate>
<GroupItem>
<Border>
<ListBox Name="GroupMemberList" ItemsSource="{Binding Path=MembersoftheCase}">
<ListBox.Triggers>
<Trigger SourceName="LButton" Property="IsChecked" Value="True">
<Setter Property="ListBox.ItemsSource" Value="{Binding Path=MembersoftheCase}"/>
<Setter Property="ListBox.ItemTemplate" Value="{StaticResource MListTemplate}"/>
</Trigger>
<Trigger SourceName="RButton" Property="IsChecked" Value="True">
<Setter Property="ListBox.ItemsSource" Value="{Binding Path=GroupsoftheCase}"/>
<Setter Property="ListBox.ItemTemplate" Value="{StaticResource GListTemplate}"/>
</Trigger>
</ListBox.Triggers>
</ListBox>
</Border>
i am Getting Exception at Compile Time the Designer is Not getting Loaded because of this Error
The property 'SourceName' does not represent a valid target for the 'Trigger' because an element named 'LButton' was not found. Make sure that the target is declared before any Setters, Triggers or Conditions that use it.
i have also tried putting the Triggers at Buttons itself making GroupmembersList as the Target
then the TargetName Could not be found is coming
F1 F1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些对象超出了文档:
如果要在外来对象上触发,请使用
DataTrigger
。 (使用ListBox.Style.Triggers
而不是立即触发器。)The objects are out of scope, from the documentation:
If you want to trigger on foreign objects use a
DataTrigger
. (Use theListBox.Style.Triggers
rather than the immediate triggers.)