프로그래밍/WPF
[WPF] 특정 컨트롤 Size 변경될 시, 값 가지고 오기
흔한티벳여우
2021. 8. 11. 12:34
반응형
ElementName에 추적하고 싶은 컨트롤 이름 물리고 땡겨오면 된다.
<UserControl.Resources>
<converter:MultiInputConverter x:Key="multiParam"/>
</UserControl.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SizeChanged">
<i:InvokeCommandAction Command="{Binding VIewSizeChangeCommand}">
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="{StaticResource multiParam}">
<Binding Path="ActualWidth" ElementName="hvView"/>
<Binding Path="ActualHeight" ElementName="hvView"/>
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
</i:EventTrigger>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding VIewSizeChangeCommand}">
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="{StaticResource multiParam}">
<Binding Path="ActualWidth" ElementName="hvView"/>
<Binding Path="ActualHeight" ElementName="hvView"/>
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
public class MultiInputConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return values.Clone();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return (object[])value;
}
}
반응형