EDIT: I bound to same property (SearchType) that combobox binds to -> works fine. I still would like to know why my first solution described here does not work.
I have
public enum SearchType
{
NetworkObjects,
Customers
}
In ViewModel contructor:
public SearchViewModel()
{
SearchType = Panels.SearchType.NetworkObjects;
In xaml:
<UserControl.Resources>
<xpui:ConvertSearchTypeToVisibility x:Key="searchtypetovisibilityconverter" />
</UserControl.Resources>
<ComboBox
Name="SearchTypeComboBox"
ItemsSource="{Binding Path=SearchTypes}"
SelectedItem="{Binding Path=SearchType, Mode=TwoWay}">
...
<DataGrid.Visibility>
<MultiBinding Converter="{StaticResource searchtypetovisibilityconverter}">
<Binding RelativeSource="{RelativeSource Self}" Path="Name"/>
<Binding ElementName="SearchTypeComboBox" Path="SelectedItem" />
</MultiBinding>
</DataGrid.Visibility>
Converter:
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string gridName = (string)values[0];
SearchType searchType = (SearchType)values[1];
In Convert-method values have 2 items and values[1]==null. Also if I take away the binding SelectedItem is SearchType.NetworkObjects as set in ViewModel constructor. What do I do wrong?