小编use*_*425的帖子

Xamarin listView 中的绑定颜色

我之前检查过一些答案,但没有任何帮助。我正在尝试通过绑定 StackLayout BackgroundColor 来更改 ListView 中 ViewCell 的背景颜色。现在它看起来像这样在此处输入图片说明

每个单元格都应该填充不同的颜色,但它根本不会改变。背后的代码:

订单数据页.XAML:

<ContentPage.Resources>
    <ResourceDictionary>
        <local:BackgroundConverter x:Key="BackgroundConverter" />
    </ResourceDictionary>
</ContentPage.Resources>
.
.
.
.
<StackLayout Orientation="Vertical">
       <ListView x:Name="timetableList"
                        RowHeight="25"
                        SeparatorVisibility="Default"
                        Margin="0,0,0,10"
                        >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal"
                                        VerticalOptions="FillAndExpand"
                                        BackgroundColor="{Binding Paint, Converter={StaticResource BackgroundConverter}}">
                                        <Label Text="{Binding Number}"
                                                FontSize="Medium"
                                                Margin="20,0,0,0"
                                                TextColor="White"
                                                BackgroundColor="Black"
                                                />
                                        <Label Text="{Binding Title}"
                                                FontSize="Default"
                                                Margin="20,0,0,0"
                                                TextColor="Black"
                                                />
                                        <Label Text="{Binding Date}"
                                                FontSize="Default"
                                                HorizontalOptions="EndAndExpand"
                                                Margin="0,0,40,0"
                                                TextColor="Black"
                                                />
                             </StackLayout>
                        </ViewCell>
                   </DataTemplate>
               </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
Run Code Online (Sandbox Code Playgroud)

转换器.cs

class BackgroundConverter : IValueConverter
{
    public object Convert(object value, Type targetType, …
Run Code Online (Sandbox Code Playgroud)

c# listview converter xamarin xamarin.forms

3
推荐指数
1
解决办法
5795
查看次数

使用单个变量进行匿名对象初始化

我发现找到了这样一条线:

var myObject = new MyClass { 42 };  
Run Code Online (Sandbox Code Playgroud)

我想知道是否可以执行此类操作.文档说,如果你定义一个匿名类型,你必须使用一个对象初始化器"所以这很明显,但我无法找到任何关于大括号中的单独整数.

.net c# object-initializers

2
推荐指数
1
解决办法
222
查看次数

IFS并在目录中移动单个位置

我有两个问题.

  1. 我在脚本中找到了以下代码行:IFS=${IFS#??} 我想了解它到底在做什么?
  2. 当我尝试从目录中的每个地方执行某些操作时,例如:

    $1 = home/user/bin/etc/something...
    
    Run Code Online (Sandbox Code Playgroud)

    所以我需要将IFS更改为"/",然后继续进行for循环

    while [ -e "$1" ]; do 
        for F in `$1`
            #do something
        done
    shift
    done
    
    Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?

linux bash shell ifs

0
推荐指数
1
解决办法
63
查看次数