mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-11-24 08:33:23 +08:00
多级可空绑定.1
This commit is contained in:
@@ -110,6 +110,7 @@
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(TargetFramework)'=='net40'">Net4</DefineConstants>
|
||||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.0|AnyCPU'">
|
||||
<Optimize>false</Optimize>
|
||||
|
||||
@@ -23,7 +23,37 @@ namespace ConsoleApp1
|
||||
{
|
||||
test = this;
|
||||
}
|
||||
[PropertyMetadata("我是默认的")]
|
||||
[PropertyMetadata(null)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)GetValue();
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class dataa : CpfObject
|
||||
{
|
||||
public data test
|
||||
{
|
||||
get
|
||||
{
|
||||
return (data)GetValue();
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(value);
|
||||
}
|
||||
}
|
||||
public dataa()
|
||||
{
|
||||
// test = new data();
|
||||
}
|
||||
[PropertyMetadata(null)]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
@@ -38,10 +68,10 @@ namespace ConsoleApp1
|
||||
}
|
||||
class MainModel : CpfObject
|
||||
{
|
||||
public data Test1 {
|
||||
public dataa Test1 {
|
||||
get
|
||||
{
|
||||
return (data)GetValue();
|
||||
return (dataa)GetValue();
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -68,7 +98,7 @@ namespace ConsoleApp1
|
||||
|
||||
public MainModel()
|
||||
{
|
||||
Test1 = new data();
|
||||
Test1 = new dataa();
|
||||
Items = new Collection<(string, string)>();
|
||||
TestItems = new Collection<(string, int)>();
|
||||
|
||||
|
||||
@@ -2454,10 +2454,32 @@ new TabItemTemplate{
|
||||
},
|
||||
new Button
|
||||
{
|
||||
Content="按钮",
|
||||
Content="创建对象",
|
||||
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
||||
{
|
||||
(DataContext as MainModel).Test1.test.test.test.test.Name = "666666";
|
||||
data a = new data();
|
||||
a.test.test.test.Name = "666666";
|
||||
(DataContext as MainModel).Test1.test = a;
|
||||
})
|
||||
},
|
||||
new Button
|
||||
{
|
||||
Content="删除对象",
|
||||
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
||||
{
|
||||
data a = new data();
|
||||
a.test.test.Name = "666666";
|
||||
(DataContext as MainModel).Test1.test.test = null;
|
||||
})
|
||||
},
|
||||
new Button
|
||||
{
|
||||
Content="添加对象",
|
||||
[nameof(Button.Click)]=new CommandDescribe((s,e)=>
|
||||
{
|
||||
data a = new data();
|
||||
a.test.test.Name = "666666";
|
||||
(DataContext as MainModel).Test1.test.test = a;
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user