4
在WPF中,如何将颜色绑定到背景色,比如viewmodel属性,会有点混乱。如何在Avalonia中绑定颜色
是否有其他方法可以绑定Avalonia中的颜色?
或者这个例子是一个好方法吗?
阿瓦隆尼亚查看
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Button.Views.MainWindow"
Title="Button" Width="700">
<StackPanel Grid.Column="2" Orientation="Vertical" Gap="8" Margin="10">
<TextBox Name="Textbox3" Text="{Binding Textbox3Text}" Foreground="{Binding Textbox3Foreground}"/>
</StackPanel>
</Window>
阿瓦隆尼亚视图模型
public class MainWindowViewModel
{
private IBrush _textbox3Foreground;
public IBrush Textbox3Foreground
{
get { return _textbox3Foreground; }
set
{
this.RaiseAndSetIfChanged(ref _textbox3Foreground, value);
}
}
public MainWindowViewModel()
{
Textbox3Foreground = Brushes.DarkOliveGreen;
}
}
谢谢,我明白了。我只是在玩阿瓦隆尼亚,它很棒! – EinApfelBaum