我有我的用户声明一个控件属性为静态资源
private StaticInfoCollection _StaticInfoColl;
public StaticInfoCollection StaticInfoColl
{
get { return _StaticInfoColl; }
set
{
if (value == _StaticInfoColl) return;
_StaticInfoColl = value;
}
}
我想能够在XAML使用这种内的属性定义。 但是每当我做财产申报如下
<UserControl.Resources>
<local:Static.StaticInfoColl x:Key="SIColl" />
</UserControl.Resources>
Static.StaticInfoColl
不XML命名空间中存在的标签clr-namespace:AAA.Presentation
有人能帮助我什么,我做错了什么?
的用户控件的名称是静态[X:姓名]
<UserControl x:Class="AAA.Presentation.ucBrand"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local ="clr-namespace:MBCL.Presentation"
mc:Ignorable="d"
d:DesignHeight="710"
d:DesignWidth="1025"
Height="710"
Width="1025"
x:Name="Static"
HorizontalAlignment="Left"
HorizontalContentAlignment="Left">
我有对他们的多个按钮的用户控件。 按钮具有一个StackPanel内,如下所示:
<Button Style="{StaticResource appViewButton}" DataContext="{Binding}" >
<StackPanel>
<TextBlock FontSize="11">View Products</TextBlock>
<TextBlock Text="{Binding Path=FileDownloadDate,StringFormat='Last Uploaded : {0:dd-MMM-yyyy}'}"
Style="{StaticResource tbUploadDate}"
HorizontalAlignment="Center" />
</StackPanel>
</Button>
我有一个实体Info
和InfoCollection
。
该按钮绑定到InfoCollection,基于FileType我想选择适当的FileDownloadDate并显示它。
public class Info
{
public Info(DataRow dr)
{
_FileType = Util.HandleNull<string>(dr[AppConstants.FILE_TYPE]);
_FileID = Util.HandleNull<long?>(dr[AppConstants.FILEID]);
_FileTypeDesc = Util.HandleNull<string>(dr[AppConstants.CODE_DESC]);
_FileDownloadDate = Util.HandleNull<DateTime>(dr[AppConstants.DOWNLOAD_DATE]);
}
private string _FileType;
public string FileType
{
get { return _FileType; }
set
{
if (value != _FileType)
_FileType = value;
}
}
private string _FileTypeDesc;
public string FileTypeDesc
{
get { return _FileTypeDesc; }
set
{
if (value != _FileTypeDesc)
_FileTypeDesc = value;
}
}
private long? _FileID;
public long? FileID
{
get { return _FileID; }
set
{
if (value != _FileID)
_FileID = value;
}
}
private DateTime _FileDownloadDate;
public DateTime FileDownloadDate
{
get { return _FileDownloadDate; }
set
{
if (value != _FileDownloadDate)
_FileDownloadDate = value;
}
}
}
public class InfoCollection : ObservableCollection<Info>
{
public InfoCollection(DataTable dtStaticInfo)
{
foreach (DataRow drSInfo in dtStaticInfo.Rows)
{
this.Add(new StaticInfo(drSInfo));
}
}
}
发表您的整个'Static'类。 –
这没有多大意义。你不能创建一个属性的实例,你可以创建一个具有这个(和更多)属性的对象实例。 “UserControl.Resources”部分用于控件中使用的其他类或对象,如画笔,动画,样式,模板等。还有什么是“静态”。在你的xaml中?一个命名空间?这就是别名“local:”的意思。请提供更多详细信息,你想要做什么。 – dowhilefor