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