문제

내 페이지의보기 모델의 속성으로 변경하여 실버 라이트 동작을 원합니다. 그러나 나는 이것을하는 방법을 알 수 없습니다.

따라서 매우 간단한보기 모델이 있습니다.

public class MyViewModel : INotifyPropertyChanged
{
    private bool changingProperty;
    public bool ChangingProperty
    {
        get { return changingProperty; }
        set
        {
            if (changingProperty != value)
            {
                changingProperty = value;
                NotifyPropertyChanged("ChangingProperty");
            }
        }
    }
    public string SomeProperty { get { return "SomePropertyValue"; } }

    // INotifyPropertyChanged implementation here.......
}

이보기 모델은 텍스트 블록이 SomeProperty:

<TextBlock x:Key="myTextBlock" Text="{Binding SomeProperty}" />

이 모든 것이 잘 작동합니다. 이제 나는 행동을 첨부하고 싶습니다 myTextBlock 그것은 변화에 의해 트리거됩니다 ChangingProperty 내 관점에서. 행동은 강조해야합니다 TextBlock, 예를 들어 (또는 더 정교한 것).

이 트리거를 어떻게 지정합니까? 이것이 전혀 가능합니까?

친절한 안부,

로널드

도움이 되었습니까?

해결책

비슷한 문제에 대한 내 대답의 선을 따라 뭔가 여기 도움이 될 수 있습니다.

다음은 해당 기술을 요구 사항에 어떻게 적용 할 수 있는지에 대한 예입니다.

<Grid.Resources>
   <local:BoolToBrushConverter x:Key="Highlighter"
    FalseBrush="Transparent" TrueBrush="Yellow" />
</Grid.Resources>

<Border Background="{Binding ChangingProperty, Converter={StaticResource Highlighter}}">
    <TextBlock x:Name="txtTarget" Text="{Binding SomeProperty}" />
</Border>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top