Reputation: 16959
I have two converters, one sets the control visibility to Hidden if the text is null. The other converts an int into a string. I'm trying to use them both below, I want to make the DockPanel Hidden if tbDisposition.Text is null, but my DockPanel binding is a bit off.
<DockPanel Visibility="{Binding Path=tbDisposition.Text, Converter={StaticResource cIsVisible}}">
<TextBlock Text="Disposition: "/>
<TextBlock Name="tbDisposition" Text="{Binding Path=SessionEvent.DispositionID, Converter={BLL:CodeMarkupExtension}}" Foreground="Blue" />
</DockPanel>
Upvotes: 4
Views: 133
Reputation: 41393
You need to use ElementName:
<DockPanel Visibility="{Binding ElementName=tbDisposition, Path=Text, Converter={StaticResource cIsVisible}}">
<TextBlock Text="Disposition: "/>
<TextBlock Name="tbDisposition" Text="{Binding Path=SessionEvent.DispositionID, Converter={BLL:CodeMarkupExtension}}" Foreground="Blue" />
</DockPanel>
Upvotes: 3
Reputation: 1401
When binding objects to a Text
property, ToString()
is automatically called on that object so there shouldn't be a need for an "int to string" converter. You can just override ToString instead.
Upvotes: 0