Hi everybody,
am new by C#.net WPF MVVM and i try to save a filename that i have got using a buttoncommand. i get the filename but the Problem is i've to do it everytime. i want to save the filename in the Combobox using a list so that i can't click to the button a second time to get it.
please excuse me for my english and thank you your help.
What I have tried:
<stackpanel orientation="Horizontal" grid.column="2" grid.row="1">
<Button Content="..." Command="{Binding SelectfilenameCommand}"
ToolTip=" wähle filename aus" Grid.Column="1" Grid.Row="1"
HorizontalAlignment="Left" Width="30" Height="20" Margin="5,1.667,5,10.333" ></Button>
<combobox name="Combo" itemssource="{Binding DataModel.ExeDateiList}" selecteditem="{Binding DataModel.DataConfig.SelectedExeDatei, Mode=TwoWay }" text="filename" horizontalalignment="Center" width="Auto" iseditable="True" isreadonly="True" margin="5,2,5,10">
My ViewModel Code:
public void Selectfilename()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Prozess (*.*)|*.*";
if (ofd.ShowDialog() == true)
{
string filename= Path.GetFileName(ofd.FileName);
this.ExeDateiList.Add(filename);
}
}