English 中文(简体)
改变受控长子或箱子的颜色
原标题:Changing an item color of a LongListSelector or Listbox that is binded

我一直在试图将<代码>TextBlock的颜色换成一个有约束力的“密码>。

<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Foreground="{Binding ItemColor, Converter={StaticResource ColorConverter}}" Style="{StaticResource posttitle}" d:LayoutOverrides="Width"/>

此处指在初始阶段工作的兑换人:

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    if (value == null)
        return new SolidColorBrush(Colors.Red);

    Color colorValue = (Color)value;

    return new SolidColorBrush(colorValue);
}

在甄选期间 改变 活动 我给该项目留下了一个新的色:

private void List_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    var listbox = (LongListSelector)sender;

    if (listbox.SelectedItem == null)
        return;

    MyItem item = (MyItem)listbox.SelectedItem;

    if (item.Clicked)
    {
        // Change some value
        item.Clicked = true;
        item.ItemColor = new Color() { A = 0xFF, R = 0xBD, G = 0xB7, B = 0x6B };
    }
}

如果我对数据内容进行分点和核对,我可以看到,来源的价值已经发生变化,但可以直观地看到<代码>。 LongListSelector没有改变眼光。 具有约束力的是<条码>可操作的孔隙和<条码>。

感谢任何帮助。

问题回答

你没有提供足够的信息,但根据你提供的准则,它像在<代码>上那样看待。 项目Color为财产 <代码>ItemColor的改动活动没有发射。

InotificationpropertyChanged和PropertyChanged(这是新的不动产,新资产ChangedEventArgs(“ItemColor”)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签