UserControl DependencyProperty
Hi,
I define a DependencyProperty in UserControl like this:
(Simplify class)
In UserControl´s xaml i code:
I obtain an exception building xaml. I attached minidump.
I define a DependencyProperty in UserControl like this:
(Simplify class)
Code: Select all
class WorkerOffice : public UserControl
{
public:
NsInt32 GetItemAsked() const
{
return DependencyObject::GetValue<NsInt32>(ItemAskedProperty);
}
void SetItemAsked(NsInt32 value)
{
DependencyObject::SetValue<NsInt32>(ItemAskedProperty, value);
}
public:
static const Gui::DependencyProperty* ItemAskedProperty;
private:
NS_IMPLEMENT_INLINE_REFLECTION(WorkerOffice, UserControl)
{
NsMeta<TypeId>("WorkerOffice");
NsProp("ItemAsked", &WorkerOffice::GetItemAsked, &WorkerOffice::SetItemAsked);
NsString source = "MyApps/CaliforniaOffice/WorkerOffice.xaml";
Ptr<UIElementData> data = NsMeta<UIElementData>(TypeOf<SelfClass>());
data->RegisterProperty<NsInt32>(ItemAskedProperty, "ItemAsked",
FrameworkPropertyMetaData::Create(NsInt32(0)));
data->OverrideMetadata<NsString>(UserControl::SourceProperty, "Source",
FrameworkPropertyMetaData::Create(source, FrameworkOptions_None));
}
};
const DependencyProperty* WorkerOffice::ItemAskedProperty;
Code: Select all
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WorkerOffice" x:Name="WorkerOffice">
....
....
<TextBlock Text="{Binding ItemAsked, ElementName=WorkerOffice}"/>
- Attachments
-
- 20120224094535.Error.rar
- (32.73 KiB) Downloaded 559 times
Re: UserControl DependencyProperty
Fixed with:
data->RegisterProperty<NsInt32>(ItemAskedProperty, "ItemAsked",
FrameworkPropertyMetaData::Create(NsInt32(50), FrameworkOptions_None));
data->RegisterProperty<NsInt32>(ItemAskedProperty, "ItemAsked",
FrameworkPropertyMetaData::Create(NsInt32(50), FrameworkOptions_None));
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 6 guests