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
6c67770d
Commit
6c67770d
authored
Mar 24, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 Item2NoConverter 列表item 转 编号,编号从1开始
parent
549e2ec5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
Dictionary_MyConv.xaml
...brary/FLY.ControlLibrary/Converter/Dictionary_MyConv.xaml
+1
-0
Item2IndexConverter.cs
...brary/FLY.ControlLibrary/Converter/Item2IndexConverter.cs
+33
-0
No files found.
Project.FLY.ControlLibrary/FLY.ControlLibrary/Converter/Dictionary_MyConv.xaml
View file @
6c67770d
...
...
@@ -24,4 +24,5 @@
<conv:RatioConverter_TimeSpan x:Key="ratioconv_ts" />
<conv:Item2IndexConverter x:Key="i2iConv"/>
<conv:Item2NoConverter x:Key="i2noConv"/>
</ResourceDictionary>
\ No newline at end of file
Project.FLY.ControlLibrary/FLY.ControlLibrary/Converter/Item2IndexConverter.cs
View file @
6c67770d
...
...
@@ -39,4 +39,37 @@ namespace FLY.ControlLibrary.Converter
throw
new
NotImplementedException
();
}
}
/// <summary>
/// 列表转Number 从1开始
/// </summary>
[
ValueConversion
(
typeof
(
object
),
typeof
(
int
))]
public
class
Item2NoConverter
:
IValueConverter
{
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
{
int
result
=
-
1
;
if
(
value
!=
null
)
{
var
collectionViewSource
=
parameter
as
CollectionViewSource
;
if
(
collectionViewSource
!=
null
)
{
var
cv
=
(
CollectionView
)
collectionViewSource
.
View
;
//在 设计模式中, View为null, 所以下面必须判断
if
(
cv
!=
null
)
{
result
=
cv
.
IndexOf
(
value
);
}
}
}
return
result
>=
0
?
result
+
1
:
System
.
Windows
.
DependencyProperty
.
UnsetValue
;
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
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