Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Framework
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.Framework
Commits
ea567a1c
Commit
ea567a1c
authored
Mar 01, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加转化器
parent
8c821add
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
0 deletions
+121
-0
VIZ.Framework.Core/Core/Converter/Bool2ControlTemplateConverter.cs
+60
-0
VIZ.Framework.Core/Core/Converter/Bool2DataTemplateConverter.cs
+59
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+2
-0
No files found.
VIZ.Framework.Core/Core/Converter/Bool2ControlTemplateConverter.cs
0 → 100644
View file @
ea567a1c
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// Bool转控件模板转化器
/// </summary>
public
class
Bool2ControlTemplateConverter
:
IValueConverter
{
/// <summary>
/// 为False时的值
/// </summary>
public
ControlTemplate
FalseResult
{
get
;
set
;
}
/// <summary>
/// 为True时的值
/// </summary>
public
ControlTemplate
TrueResult
{
get
;
set
;
}
/// <summary>
/// 为null时的值
/// </summary>
public
ControlTemplate
NullResult
{
get
;
set
;
}
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(
value
is
bool
?)
{
bool
?
b
=
(
bool
?)
value
;
if
(
b
==
null
)
return
this
.
NullResult
;
return
b
.
Value
?
this
.
TrueResult
:
this
.
FalseResult
;
}
else
if
(
value
is
bool
)
{
bool
b
=
(
bool
)
value
;
return
b
?
this
.
TrueResult
:
this
.
FalseResult
;
}
else
{
return
this
.
NullResult
;
}
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/Core/Converter/Bool2DataTemplateConverter.cs
0 → 100644
View file @
ea567a1c
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Data
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// Bool转数据模板转化器
/// </summary>
public
class
Bool2DataTemplateConverter
:
IValueConverter
{
/// <summary>
/// 为False时的值
/// </summary>
public
DataTemplate
FalseResult
{
get
;
set
;
}
/// <summary>
/// 为True时的值
/// </summary>
public
DataTemplate
TrueResult
{
get
;
set
;
}
/// <summary>
/// 为null时的值
/// </summary>
public
DataTemplate
NullResult
{
get
;
set
;
}
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(
value
is
bool
?)
{
bool
?
b
=
(
bool
?)
value
;
if
(
b
==
null
)
return
this
.
NullResult
;
return
b
.
Value
?
this
.
TrueResult
:
this
.
FalseResult
;
}
else
if
(
value
is
bool
)
{
bool
b
=
(
bool
)
value
;
return
b
?
this
.
TrueResult
:
this
.
FalseResult
;
}
else
{
return
this
.
NullResult
;
}
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
ea567a1c
...
...
@@ -93,6 +93,8 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Core\Converter\Bool2ControlTemplateConverter.cs" />
<Compile Include="Core\Converter\Bool2DataTemplateConverter.cs" />
<Compile Include="Core\Converter\Bool2ImageSourceConverter.cs" />
<Compile Include="Core\Converter\Bool2BoolConverterSimple.cs" />
<Compile Include="Core\Converter\Bool2BoolConverter.cs" />
...
...
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