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>
AvaloniaのViewModel
public class MainWindowViewModel
{
private IBrush _textbox3Foreground;
public IBrush Textbox3Foreground
{
get { return _textbox3Foreground; }
set
{
this.RaiseAndSetIfChanged(ref _textbox3Foreground, value);
}
}
public MainWindowViewModel()
{
Textbox3Foreground = Brushes.DarkOliveGreen;
}
}
ありがとうございました。私はあの偉大なアバロニアで遊んでいます! – EinApfelBaum