0
我想綁定scrollBarVisibility
和checkBox
屬性IsChecked
。 如果IsChecked
爲真scrollBarVisibility
需要可見。綁定複選框到ScrollBar.Visibility
XAML:
<Controls:MetroWindow.Resources>
<local:Nustatymai x:Key="checkBox_keitejas" />
</Controls:MetroWindow.Resources>
<!-- ..... -->
<ScrollViewer Name="tempimas" IsEnabled="True" VerticalScrollBarVisibility="Disabled"
Height="795" HorizontalScrollBarVisibility="{Binding IsChecked, ElementName=check1,
Converter={StaticResource checkBox_keitejas}}" >
</ScrollViewer>
<!-- ..... -->
<WrapPanel>
<TextBlock>Rodyti apatini scrollBar</TextBlock>
<CheckBox Name="check1" IsChecked="True"/>
</WrapPanel>
C#:
class Nustatymai : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value == true)
return ScrollBarVisibility.Visible;
else
return ScrollBarVisibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
現在這個代碼是不是爲我工作,我需要你的幫助來解決吧!
即使滾動條不可見,滾動條也不會顯示/隱藏或內容仍然可以滾動? – dkozl