Problem I encountering is that my TextBox
doesn't hide nor becoming visible when I'm changing ObservableCollection
bool value IsFoo
. I can't figure out why is this happening. Am I missing something?
Model using for ObservableCollection`
public class FooModel: Model
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsFoo { get; set; }
public string FooStr{ get; set; }
}
Model using between ViewModel
and View
public class SomeModel: Model
{
public Model()
{
FooModels= new ObservableCollection<FooModel>();
}
private ObservableCollection<FooModel> _fooModels;
public ObservableCollection<FooModel> FooModels
{
get => _fooModels;
set => SetProperty(ref _fooModels, value);
}
}
View
<ItemsControl FontWeight="Normal" ItemsSource="{Binding Model.FooModels}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type models:FooModel}">
<DockPanel HorizontalAlignment="Left">
<CheckBox
HorizontalAlignment="Right"
Content="{Binding Name}"
DockPanel.Dock="Left"
IsChecked="{Binding IsFoo}" />
<TextBox
DockPanel.Dock="Right"
Style="{StaticResource SimpleTextBox}"
Text="{Binding FooStr}"
Visibility="{Binding IsFoo, Converter={StaticResource BooleanToVisibilityHideConverter}}" />
</DockPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>