0
我正嘗試使用在我的後臺代理中引用的另一個項目中找到的用戶控件從後臺代理創建自定義活動磁貼。使用UserControl進行自定義活動瓦片的原因System.IO.FileNotFoundException
我的用戶:
<UserControl x:Class="livetile.smalltile"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="159" d:DesignWidth="159">
<Canvas x:Name="LayoutRoot" Background="#ea6060" Width="159" Height="159">
<TextBlock Text="{Binding day}" Width="159" TextAlignment="Center" FontFamily=".\Fonts\Helvetica-Light.otf#Helvetica Light" FontSize="100" Foreground="White"/>
<TextBlock Text="{Binding dayofweek}" Width="159" TextAlignment="Center" Canvas.Top="100" FontFamily=".\Fonts\Helvetica-Light.otf#Helvetica Light" FontSize="30" Margin="0,0,0,25" Foreground="White"/>
</Canvas>
</UserControl>
我身後代碼:
public partial class smalltile : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string p)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(p));
}
private string _day;
public string day
{
get { return _day; }
set
{
if (_day == value) return;
_day = value;
NotifyPropertyChanged("day");
}
}
private string _dayofweek;
public string dayofweek
{
get { return _dayofweek; }
set
{
if (_dayofweek == value) return;
_dayofweek = value;
NotifyPropertyChanged("dayofweek");
}
}
public smalltile()
{
InitializeComponent();
this.DataContext = this;
}
}
在我的後臺代理代碼:
var smalltilevar = new smalltile();
smalltilevar.day = DateTime.Now.Day.ToString();
smalltilevar.dayofweek = DateTime.Now.DayOfWeek.ToString();
smalltilevar.Measure(new Size(159, 159));
smalltilevar.Arrange(new Rect(0, 0, 159, 159));
當使用斷點我看到它的構造函數中墜毀我的UserControl出現以下錯誤:
An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll
我真的不知道我在做什麼錯?