Để Bind từ ScrollBar đến Label trong WPF ta sử dụng đoạn mã XAML sau.
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollBar Orientation="Horizontal" Margin="24" Maximum="100" LargeChange="10" SmallChange="1" Value="{Binding ElementName=lbl, Path=Content}" /> <Label Name="lbl" Content="50" HorizontalAlignment="Center" /> </StackPanel>
Kết quả