Cześć :) Uczę się pisać aplikacje w WPF mam taki kod :)
PostView:
<TextBox Grid.Row="0" Grid.Column="0"
x:Name="Content"
Tag="Content"
Text="{Binding Path=Content}"></TextBox>
PostViewModel:
public PostViewModel(IResponseService _responseService, IEventAggregator _eventAggregator)
{
PublishCommand = new RelayCommand(PublishPost);
SaveAsCommand = new RelayCommand(SaveAsPost);
OpenCommand = new RelayCommand(OpenPost);
PrintCommand = new RelayCommand(PrintPost);
LogoutCommand = new RelayCommand(Logout);
GoToMenuCommand = new RelayCommand(GoToMenu);
responseService = _responseService;
eventAggregator = _eventAggregator;
GetCategories();
GetTags();
}
#endregion
#region PROPERTIES
public string Content
{
get { return _content; }
set
{
_content = value;
OnPropertyChanged(ref _content, value);
}
}
oraz napisałem taką metodę :)
private void AddImage()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "PNG Image (*.png)|*.png|JPG Image (*.jpg)| *.jpg";
string filename = string.Empty;
if (openFileDialog.ShowDialog() == true)
{
filename = openFileDialog.FileName;
}
string result = $"<img src='{filename}' />";
Content += result;
}
I Mam takie pytanie czy jest możwliość aby za pomocą buttona móc wstawić tag html i aby ten obrazek był widoczny po wstawieniu na textboxie ? :)