So I found a list of Converters on MSDN today, now I want to use some of them. However after searching a bit I can t seem to find ANYTHING about them.
I mainly want to use the IntToBoolConverter. However I got no clue how to use the convert since there is no info provided how to do it(or on google).
I know it is easy to make this converter myself, but I am a programmer and my moto is be lazy when you can and making methods(converters) that already exists is redundant work.
Hope someone can explain to me how to use these converters.
EDIT:
After trying the reply I get error on loading the usercontrol:
{"Cannot find resource named 'IntToVisibleConverter'. Resource names are case sensitive."}
App.xaml
<Application x:Class="Smartp1ck.JungleTimerClient.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:msconv="clr-namespace:Microsoft.TeamFoundation.Controls.WPF.Converters;assembly=Microsoft.TeamFoundation.Controls">
<Application.Resources>
<msconv:IntToVisibleConverter x:Key="IntToVisibleConverter" />
</Application.Resources>
</Application>
And on the usercontrol
<TextBlock Text="{Binding TimeLeft}" HorizontalAlignment="Center" Visibility="{Binding Path=TimeLeft, Converter={StaticResource IntToVisibleConverter}}" />
EDIT2:
Puting it in the Resources of the usercontrol makes it work. Too bad I can t use the app.xaml for some reason I ll figuere it out later. Thanks for the help, solved!
Maxim
You will have to add
Microsoft.TeamFoundation.Controls.dll
as a reference in your app and xaml, then you can declare the converter in your window resources and use in your application.Example:
If you want to use the converter globally throughout your application (other windows/dialogs etc) you can define the converter in the
App.xaml
Example:
you can access this the same as the first example
Converter={StaticResource IntToBoolConverter}