Reputation: 1085
I have a toggle button which i bind its 'Tag' property to an object. I then bind the 'IsChecked' property to its 'Tag' property. My problem is that the 'IsChecked' is called first when the window loads and the 'Tag' second. How could i make the 'Tag' property bind first?
<ToggleButton>
<ToggleButton.Tag>
<Bind An Object...>
</ToggleButton.Tag>
<ToggleButton.IsChecked>
<Binding Converter="{StaticResource SomeConverter}" Path="Tag" RelativeSource="{RelativeSource Self}"/>
</ToggleButton.IsChecked>
</ToggleButton>
Upvotes: 1
Views: 1811
Reputation: 178780
Why does order matter? Is it because your converter doesn't handle the case when the value is null
, because it should - even if it returns Binding.DoNothing
. When Tag is set to something, your IsChecked binding should refresh and your converter should run again. Is that not the case?
Upvotes: 4
Reputation: 16656
You can bind this source (source what you binding to Tag
) directly to Tag
and IsChecked
, then you don't have IsChecked
binding dependend on Tag
and you dont care about race condition and you don't need any order.
Upvotes: 1