Hy Supportteam,
i've the following problem.I want to bind the Property "CloseButtonVisibility" to my ViewModel.I've played arroung with serveral things, but nothing helps.Here is my samplecode.
<igWindows:XamTabControl Theme="[Current]" ItemsSource="{Binding Path=LoadedViewModels}" IsSynchronizedWithCurrentItem="True"igWindows:TabItemEx.Closed="OnTabItemExClosed" ><igWindows:XamTabControl.Resources><Style TargetType="igWindows:TabItemEx"><Setter Property="HeaderTemplate" Value="{StaticResource headerText}" /></Style></igWindows:XamTabControl.Resources></igWindows:XamTabControl>
The Itemssource "LoadedViewModels" is a collecetion of my viewmodels and each has a bool prop for viewmodelcanclose.
Can you help my?
Hello, I am attaching a sample application that shows how you can bind the CloseButtonVisibility to a property of the view model object. The sample application uses the following style for the TabItemEx:
<Style TargetType="igWindows:TabItemEx"> <Setter Property="Header" Value="{Binding HeaderText}" /> <Setter Property="CloseButtonVisibility" Value="{Binding CanClose,Converter={StaticResource BoolToVisibility}}"/> </Style>
Which bind the header of the TabItemEx to property called HeaderText and the CloseButtonVisibility to CanClose property of the view model with the following converter:
public class BoolToVisibilityconverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) { if ((bool)value) { return TabItemCloseButtonVisibility.Visible; } else { return TabItemCloseButtonVisibility.Hidden; } } return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }
Converting the bool value to TabItemExCloseButtonVisibility.
If you require any further clarifications please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Dear Kasimir,
thank you for your support.Your soulution solved my problem.
Sometimes you can't see the mistake.My converter was wrong and I changed it and yea.