Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# DataTrigger不处理嵌套的依赖项属性_C#_Wpf_Triggers_Datatrigger - Fatal编程技术网

C# DataTrigger不处理嵌套的依赖项属性

C# DataTrigger不处理嵌套的依赖项属性,c#,wpf,triggers,datatrigger,C#,Wpf,Triggers,Datatrigger,我有以下几个类(TextListClass和TextEntryClass) C#代码 无论何时选择新的TextEntryClass,都会显示新的Text(获得单独的DataTemplate。忽略以保留调查)。但我还想更改FooControl的FooProperty,该属性不起作用(触发器未触发)。尝试{relativesourceself}: <DataTrigger Binding="{Binding Path=SelectedText.Type, RelativeSource={Rel

我有以下几个类(
TextListClass
TextEntryClass

C#代码
无论何时选择新的
TextEntryClass
,都会显示新的
Text
(获得单独的
DataTemplate
。忽略以保留调查)。但我还想更改
FooControl
FooProperty
,该属性不起作用(触发器未触发)。

尝试
{relativesourceself}

<DataTrigger Binding="{Binding Path=SelectedText.Type, RelativeSource={RelativeSource Self}}" 
                                         Value="{x:Static Controls:ETextEntryType.One}">
    <Setter TargetName="fooControlName" Property="FooProperty" Value="FooValue"/>
</DataTrigger>

试试
{relativesourceself}

<DataTrigger Binding="{Binding Path=SelectedText.Type, RelativeSource={RelativeSource Self}}" 
                                         Value="{x:Static Controls:ETextEntryType.One}">
    <Setter TargetName="fooControlName" Property="FooProperty" Value="FooValue"/>
</DataTrigger>


您正在做什么来尝试更改按钮的内容?您想将其更改为什么?我想更改
CustomControl
CustomProperty
。对于这个例子,我刚刚使用了一个简单的
按钮
。我已经换了。哦,好的,对不起。请尝试使用DataTrigger.Value的
Value=“One”
。我将在45分钟后到达办公室,并尝试使用您的代码。您如何尝试更改按钮的内容?您想将其更改为什么?我想更改
CustomControl
CustomProperty
。对于这个例子,我刚刚使用了一个简单的
按钮
。我已经换了。哦,好的,对不起。试试看DataTrigger.Value,我45分钟后就到办公室,试试你的代码。你太棒了!你能告诉我为什么我必须使用
RelativeSource={RelativeSource Self}
而不是
RelativeSource={RelativeSource Mode=TemplatedParent}
?我想你的意思是用它来代替{RelativeSource TemplatedParent}。这是因为ControlTemplate触发器没有TemplatedParent。你太棒了!你能告诉我为什么我必须使用
RelativeSource={RelativeSource Self}
而不是
RelativeSource={RelativeSource Mode=TemplatedParent}
?我想你的意思是用它来代替{RelativeSource TemplatedParent}。这是因为ControlTemplate触发器没有TemplatedParent。
<DataTrigger Binding="{Binding Path=SelectedText.Type, RelativeSource={RelativeSource Self}}" 
                                         Value="{x:Static Controls:ETextEntryType.One}">
    <Setter TargetName="fooControlName" Property="FooProperty" Value="FooValue"/>
</DataTrigger>