LoginSignup
0
1

More than 5 years have passed since last update.

添付プロパティをBindingのPathに指定する場合はカッコを付ける

Posted at

BindingのPathに添付プロパティを指定する場合、カッコをつけないと「BindingExpression path error」になる。

XAML
<Window x:Class="Sample.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Sample"
        Title="MainView" Height="300" Width="300">
    <Grid>
        <TextBox>
            <TextBox.Style>
                <Style TargerType="TextBox">
                    <Style.Triggers>
                        <!--Pathにカッコを付ける-->
                        <DataTrigger Binding="{Binding Path=(local:AttachedXXX.XXX), RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="Background" Value="Blue"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBox.Style>
        </TextBox>
    </Grid>
</Window>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1