이 문제에 대해 환경을 설명하겠습니다.UserControl 닫기 트리거가 실행되지 않음
XAML에서 UserControl을 사용하고 있는데 코드가 제대로 작동하지 않아 XAML 부분에서 모두해야했습니다. Window 코드에 대한 액세스 권한도 없습니다. 창 위치를 저장해야하는 사용자 컨트롤 만.
문제는 내 가까운 트리거는 트리거되지 않습니다 (그러나 취소 버튼이 트리거 잘 작동 코드에 더 클릭)
내가 액세스를했습니다 코드의 유일한 부분에 도달 할 수 있습니다. userCommandBuilder 때문에 리소스 앞에 트리거를 넣을 수 없습니다.
트리거.
<UserControl
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
...otherstuff...
MinWidth="946" MinHeight="902" MaxWidth="946" MaxHeight="902">
<UserControl.Resources.../>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Close">
<i:InvokeCommandAction Command="{x:Static addin:AddInCommands.ExecuteCmdLine}" >
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="{StaticResource userCommandBuilder}" ConverterParameter="SRSAVEPOSITION -T {0} -L {1}">
<Binding RelativeSource="{RelativeSource AncestorType={x:Type Window}}" Path="Top" />
<Binding RelativeSource="{RelativeSource AncestorType={x:Type Window}}" Path="Left" />
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
내가 잘못 했습니까? 어떻게 해결할 수 있습니까?
버튼 코드를
<Button Margin="0,0,0,0" IsCancel="True" FontSize="13" FontFamily="Segoe UI">Cancel>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{x:Static addin:AddInCommands.ExecuteCmdLine}" >
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="{StaticResource userCommandBuilder}" ConverterParameter="SRSAVEPOSITION -T {0} -L {1}">
<Binding RelativeSource="{RelativeSource AncestorType={x:Type Window}}" Path="Top" />
<Binding RelativeSource="{RelativeSource AncestorType={x:Type Window}}" Path="Left" />
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
<i:InvokeCommandAction Command="ApplicationCommands.Close" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
당신이'Cancel'의 코드를 가지고 적이 있습니까? 그래서 우리는 비교할 수 있습니다. – XAMlMAX
예, 취소 버튼 코드로 tommorow로 돌아 왔습니다. – Eidan
코드가 추가되었습니다. Close 이벤트와 크게 다르지 않습니다. close 이벤트 또는 언로드 된 이벤트가 usercontrol에 없으면이 방법을 수행 할 방법이 표시되지 않습니다. – Eidan