有时,在不可重现的情况下,我的WPF应用程序崩溃而没有任何消息.应用程序立即关闭.
实现全局Try/Catch块的最佳位置在哪里.至少我必须实现一个消息框:"抱歉给您带来不便......"
为了描述我的问题,我创建了一个小应用程序。首先,用户控件:
<UserControl x:Class="WpfApplication10.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="This" DataContext="{Binding ElementName=This}"
>
<Image Source="{Binding Path=MyImageSource}" ></Image>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
第二个TestApp:
<Window x:Class="WpfApplication10.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfApplication10="clr-namespace:WpfApplication10"
Title="Window1" Height="300" Width="300">
<WpfApplication10:UserControl1
MyImageSource="c:\test.png" >
</WpfApplication10:UserControl1>
</Window>
Run Code Online (Sandbox Code Playgroud)
第三条用户控件背后的代码
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace WpfApplication10
{
public partial class UserControl1 : UserControl
{
public static readonly DependencyProperty MyImageSourceProperty =
DependencyProperty.Register("MyImageSource",
typeof(BitmapImage),typeof(UserControl1),
new FrameworkPropertyMetadata((BitmapImage)new BitmapImage(),
FrameworkPropertyMetadataOptions.None
));
public BitmapImage MyImageSource
{
get { return (BitmapImage)GetValue(MyImageSourceProperty); }
set { SetValue(MyImageSourceProperty, value); }
}
public UserControl1()
{
InitializeComponent();
}
}
} …
Run Code Online (Sandbox Code Playgroud) 我必须开发一个wpf控件,它应该具有与众所周知的边界相同的行为.控制的形状应该是新的部分.每个可定义的封闭路径应用于定义控制的外观.
我需要帮助来实现这一目标.目前我不知道如何将矩形(??)与闭合路径互换.
任何帮助将受到高度赞赏.