回答編集履歴
2
動画入れ替え
answer
CHANGED
@@ -124,4 +124,4 @@
|
|
124
124
|
=> throw new NotImplementedException();
|
125
125
|
}
|
126
126
|
```
|
127
|
-

|
1
簡単な例 追加
answer
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
Height="200">
|
23
23
|
<Window.Resources>
|
24
24
|
<local:MultiValueEqualityConverter x:Key="multiValueEqualityConverter" />
|
25
|
+
<local:LessThanConverter x:Key="lessThanConverter" />
|
25
26
|
</Window.Resources>
|
26
27
|
<DockPanel>
|
27
28
|
<Button
|
@@ -50,12 +51,42 @@
|
|
50
51
|
</Style>
|
51
52
|
</Button.Style>
|
52
53
|
</Button>
|
54
|
+
|
55
|
+
<!-- こういうのもあり -->
|
56
|
+
<Button
|
57
|
+
Margin="10"
|
58
|
+
Command="ScrollBar.PageRightCommand"
|
59
|
+
CommandTarget="{Binding ElementName=ScrollViewerA}"
|
60
|
+
Content="PageRight"
|
61
|
+
DockPanel.Dock="Bottom">
|
62
|
+
<Button.IsEnabled>
|
63
|
+
<MultiBinding Converter="{StaticResource lessThanConverter}">
|
64
|
+
<Binding ElementName="ScrollViewerA" Path="HorizontalOffset" />
|
65
|
+
<Binding ElementName="ScrollViewerA" Path="ScrollableWidth" />
|
66
|
+
</MultiBinding>
|
67
|
+
</Button.IsEnabled>
|
68
|
+
<Button.Style>
|
69
|
+
<Style TargetType="Button">
|
70
|
+
<Style.Triggers>
|
71
|
+
<Trigger Property="IsEnabled" Value="True">
|
72
|
+
<Setter Property="Effect">
|
73
|
+
<Setter.Value>
|
74
|
+
<DropShadowEffect BlurRadius="20" ShadowDepth="0" Color="Blue" />
|
75
|
+
</Setter.Value>
|
76
|
+
</Setter>
|
77
|
+
</Trigger>
|
78
|
+
</Style.Triggers>
|
79
|
+
</Style>
|
80
|
+
</Button.Style>
|
81
|
+
</Button>
|
82
|
+
|
53
83
|
<ScrollViewer x:Name="ScrollViewerA" HorizontalScrollBarVisibility="Visible">
|
54
84
|
<TextBlock Text="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" />
|
55
85
|
</ScrollViewer>
|
56
86
|
</DockPanel>
|
57
87
|
</Window>
|
58
88
|
```
|
89
|
+
|
59
90
|
```cs
|
60
91
|
using System.Globalization;
|
61
92
|
using System.Windows;
|
@@ -72,10 +103,25 @@
|
|
72
103
|
// [.net - Using binding for the Value property of DataTrigger condition - Stack Overflow](https://stackoverflow.com/questions/2240421/using-binding-for-the-value-property-of-datatrigger-condition)
|
73
104
|
public class MultiValueEqualityConverter : IMultiValueConverter
|
74
105
|
{
|
75
|
-
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
106
|
+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
76
107
|
=> values?.All(o => o?.Equals(values[0]) == true) == true || values?.All(o => o == null) == true;
|
77
|
-
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
108
|
+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
78
109
|
=> throw new NotImplementedException();
|
79
110
|
}
|
111
|
+
|
112
|
+
|
113
|
+
public class LessThanConverter : IMultiValueConverter
|
114
|
+
{
|
115
|
+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
116
|
+
{
|
117
|
+
var d1 = (double)values[0]; // HorizontalOffset
|
118
|
+
var d2 = (double)values[1]; // ScrollableWidth
|
119
|
+
//スクロール位置が右端に到達していなかったら(まだスクロールできる状態であれば)
|
120
|
+
return d1 < d2;
|
121
|
+
}
|
122
|
+
|
123
|
+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
124
|
+
=> throw new NotImplementedException();
|
125
|
+
}
|
80
126
|
```
|
81
127
|

|