Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Select datacard when button in header is clicked
posted

Hi, I have customized the datacard styling, including an info button in the header. When the info button is clicked, I would like to show more information about the specific datacard. The problem now is that the datacard needs to be selected first. I would like it to be selected before the button's click is handled.

I would like the same behavior for the expand/collapse button, so when it is clicked the datacard is also selected.

The Button is within the ControlTemplate of the CardHeaderPresenter:

<Button x:Name="BtnInfo"
Style="{StaticResource BtnInfoImageSq}"
Command="{Binding DataContext.DcShowOrderDetails, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
Width="20" Height="20"
HorizontalAlignment="Right"
Grid.Column="2"
Margin="5">
</Button>

It tried to bind the IsActive and IsSelected Properties within the CardViewCard style to its IsKeyboardFocusWithin property like so:

<DataTrigger Binding="{Binding Path=IsKeyboardFocusWithin, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="IsSelected" Value="True"/>
<Setter Property="IsActive" Value="True"/>
<Setter TargetName="Bd" Property="BorderBrush" Value="Pink"/> <!-- test, this works, datatrigger is firing -->
</DataTrigger>

The IsSelected and IsActive properties are not changing with the IsKeyBoardFocusWithin property, while the borderbrush does. It seems to me that the DataTrigger doesn't 'know' where the properties belong to, but I can't find out how to fix this.

Anyone who can show me the right way to solve this with the currently provided info?

Parents Reply Children
No Data