Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
ee80935a
Commit
ee80935a
authored
Mar 30, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ParamDictionary 添加绑定功能
parent
489fb855
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
ParamDictionary.cs
Project.FLY.Misc/MISC/ParamDictionary.cs
+20
-6
No files found.
Project.FLY.Misc/MISC/ParamDictionary.cs
View file @
ee80935a
...
...
@@ -133,12 +133,26 @@ namespace Misc
/// <param name="propertyName"></param>
/// <param name="defaultValue"></param>
public
void
SetBinding
<
T
>(
INotifyPropertyChanged
target
,
string
propertyName
,
T
defaultValue
)
{
SetBinding
<
T
>(
target
,
propertyName
,
propertyName
,
defaultValue
);
}
/// <summary>
/// 双向绑定
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="src"></param>
/// <param name="target"></param>
/// <param name="propertyName"></param>
/// <param name="key"></param>
/// <param name="defaultValue"></param>
public
void
SetBinding
<
T
>(
INotifyPropertyChanged
target
,
string
propertyName
,
string
key
,
T
defaultValue
)
{
Type
type_s
=
target
.
GetType
();
System
.
Reflection
.
PropertyInfo
pi_t
=
type_s
.
GetProperty
(
propertyName
);
if
(
pi_t
==
null
)
return
;
object
obj
=
GetValue
<
T
>(
propertyName
,
defaultValue
);
object
obj
=
this
.
GetValue
<
T
>(
key
,
defaultValue
);
pi_t
.
SetValue
(
target
,
obj
);
target
.
PropertyChanged
+=
(
s
,
e
)
=>
...
...
@@ -146,19 +160,19 @@ namespace Misc
if
(
e
.
PropertyName
==
propertyName
)
{
object
o
=
pi_t
.
GetValue
(
target
);
SetValue
(
propertyName
,
o
);
this
.
SetValue
(
key
,
o
);
}
};
ValueChanged
+=
(
s
,
e
)
=>
{
if
(
e
.
Key
==
propertyName
)
{
object
o
=
GetValue
<
T
>(
propertyName
,
defaultValue
);
pi_t
.
SetValue
(
target
,
o
);
if
(
e
.
Key
==
key
)
{
pi_t
.
SetValue
(
target
,
e
.
Value
);
}
};
}
private
string
path
;
public
event
UiParamDictionaryValueChangedHandler
ValueChanged
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment