0
votes
   <Grid>
      <CheckBox  Content="Select All" IsChecked="{Binding Path=SelectAll}"/>
      <TextBlock Grid.Column="1" Text="Filter by:"  />
      <RadioButton IsChecked="{Binding Path=All}" GroupName="filterGroup" Content="All" />
      <RadioButton IsChecked="{Binding Path=NShared}" GroupName="filterGroup" Content="Not Shared" />
   </Grid>
   <GroupBox Header="Members" Style="{StaticResource CenteredHeaderGroupBoxStyle}" Width="330">
      <GroupBox.HeaderTemplate>
           <DataTemplate>
                <Border Width="320">
                    <Grid HorizontalAlignment="Center" Width="320">
                       <ToggleButton Name="LeftButton" Command="{Binding Path=MemeberButtonSelected}"/>
                       <ToggleButton Name="RightButton" IsChecked="{Binding Path=GroupSelected}"/>
                     </Grid>
                 </Border>
            </DataTemplate>
       </GroupBox.HeaderTemplate>
       <GroupItem>
          <Border>
            <ListBox Name="GroupMemberList">
                <ListBox.Style>
                    <Style>
                       <Style.Triggers>
                           <DataTrigger Binding="{Binding Path=GroupSelected}" Value="True">
                                <Setter Property="ListBox.ItemsSource" Value="{Binding Path=GroupsoftheCase}"/>
                                <Setter Property="ListBox.ItemTemplate" Value="{StaticResource GroupListTemplate}"/>
                                <Setter Property="ListBox.SelectedValue" Value="{Binding Path=SelectedGroups}"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=MemberSelected}" Value="True">
                                <Setter Property="ListBox.ItemsSource" Value="{Binding Path=MembersoftheCase}"/>
                                <Setter Property="ListBox.ItemTemplate" Value="{StaticResource MembersListTemplate}"/>
                                <Setter Property="ListBox.SelectedValue" Value="{Binding Path=SelectedMembers}"/>
                            </DataTrigger>
                       </Style.Triggers>
                    </Style>
                </ListBox.Style>
             </ListBox>
          </Border>
       </GroupItem>
   </GroupBox>

The ToggleButton Binding is Not working the Properties/Commands are existing in the DataContext of the View

but the output says

System.Windows.Data Error: 40 : BindingExpression path error: 'MemeberButtonSelected' property not found on 'object' ''String' (HashCode=-1399923548)'. BindingExpression:Path=MemeberButtonSelected; DataItem='String' (HashCode=-1399923548); target element is 'ToggleButton' (Name=''); target property is 'Command' (type 'ICommand')


System.Windows.Data Error: 40 : BindingExpression path error: 'GroupSelected' property not found on 'object' ''String' (HashCode=-1399923548)'. BindingExpression:Path=GroupSelected; DataItem='String' (HashCode=-1399923548); target element is 'ToggleButton' (Name=''); target property is 'IsChecked' (type 'Nullable`1')

i have also tried the Relative Source

as

 IsChecked="{Binding Path=MemberSelected, RelativeSource={RelativeSource AncestorType={x:Type GroupBox}}}"

for one of the Toggle buttons and its of no Use only the String in the output will change to object thats all

2
Are you sure there are no typos? MemeberButtonSelected looks like a typo. Also, in the relative path example, you called it MemberSelected.Daniel Hilgarth

2 Answers

2
votes

The Header of your GroupBox is a string ("Members"), so the DataContext in the HeaderTemplate is also a string... and there is no MemeberButtonSelected property on type String, as mentioned in the error message. You need to bind to the DataContext of the GroupBox:

...
<Grid HorizontalAlignment="Center" Width="320">
   <ToggleButton Name="LeftButton" Command="{Binding Path=DataContext.MemeberButtonSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GroupBox}}}"/>
   <ToggleButton Name="RightButton" IsChecked="{Binding Path=DataContext.GroupSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GroupBox}}}"/>
 </Grid>
...
0
votes

What is the DataContext object type you are passing into that? Your output says string, so somewhere you are getting the wrong data. Try setting a breakpoint after every instance where whatever data you are binding to is updated. Alternatively, if you have Mole you can use that to look at items datacontext directly.