我有一个附加关闭和打开处理程序的Flyout模板,但没有被称为
<Flyout x:Key="CameraFlyout" Placement="Right" Closed="CameraClosed" Opened="CameraOpened">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="ScrollViewer.ZoomMode" Value="Enabled"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Height" Value="400"/>
<Setter Property="Width" Value="300"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<attachment:CameraCaptureControl x:Name="userControl" DataContext="{Binding}" />
</Flyout>
弹出按钮附加到按钮
<Button DataContext="{Binding CameraViewModel}"
BorderThickness="0"
Background="Transparent"
Flyout="{StaticResource CameraFlyout}"
Content"Camera"/>
应该有一些我在这里遗失的明显事物。 Flyout工作我被解雇后无法清理,这很糟糕。
处理程序在包含ResourceDictionary的弹出模板后面的代码中定义。
public void CameraClosed(object sender, object o)
{
CameraCaptureControl.CleanupCaptureResources(sender);
}
public void CameraOpened(object sender, object e)
{
CameraCaptureControl.Initialize(sender);
}