Hej,
ive got a ListBox binded to a ObservableCollection and now im trying to Implement a Search / Filter Function. But its not working... tried everything :(
Heres a Picture of my ListBox http://i.imgur.com/el8KF3T.png
Ok ive got the Solution thanks to Maximus's Link. Ive Updated my Code.
and heres what i tried so far my .xaml code
<ListBox Name="lstWarning" Margin="-14,3,-31,-30">
<ListBox.ItemTemplate>
<DataTemplate>
<Canvas Height="62" Width="582">
<Label Foreground="#FFA8A4A4" FontFamily="{DynamicResource HeaderFontFamily}" FontSize="11" Content="{Binding DirName}" Canvas.Left="39" Canvas.Top="23"/>
<Label Foreground="#FFA8A4A4" FontFamily="{DynamicResource HeaderFontFamily}" FontSize="11" Content="{Binding CreationDate}" Canvas.Left="39" Canvas.Top="40"/>
<Label Foreground="White" FontFamily="{DynamicResource HeaderFontFamily}" FontSize="14" Content="{Binding FileName}" Canvas.Left="39" Canvas.Top="4"/>
<Label Foreground="#FFA8A4A4" FontFamily="{DynamicResource HeaderFontFamily}" FontSize="11" Content="{Binding Extension}" Canvas.Left="224" Canvas.Top="40"/>
<Label Foreground="#FFA8A4A4" FontFamily="{DynamicResource HeaderFontFamily}" FontSize="11" Content="{Binding FileSize}" Canvas.Left="155" Canvas.Top="40"/>
<Image Source="{Binding StatusImage}" Width="30" Height="30" Canvas.Left="10" Canvas.Top="6" Stretch="Fill"/>
</Canvas>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And heres what if done in the TextChanged Event
private void cmdSearchWarnings_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) {
CollectionView cv = (CollectionView)CollectionViewSource.GetDefaultView(lstWarning.ItemsSource);
if (!string.IsNullOrEmpty(txtSearchWarnings.Text)) {
if (isFilter) {
cv.Filter = null;
isFilter = false;
}
else {
cv.Filter = new Predicate<object>(FilterByFileName);
isFilter = true;
}
}
else {
cv.Filter = null;
isFilter = false;
}
}
private bool FilterByFileName(object _warningObj) {
if (_warningList != null) {
if (!string.IsNullOrEmpty(txtSearchWarnings.Text)) {
var warning = _warningObj as WarningItem;
return warning.FileName.Trim().Contains(txtSearchWarnings.Text);
}
}
return false;
}
And heres my WarningItem Class Code:
public class WarningItem
{
public string FullPath { get; set; }
public string DirName { get; set; }
public string FileName { get; set; }
public string FileSize { get; set; }
public string CreationDate { get; set; }
public string Extension { get; set; }
public Uri StatusImage { get; set; }
}
I am pasting simple example but similar was covered countless time you need to delve in SO. Following sample checks whether collection Names containts element which in turn containt searching word.
private ObservableCollection<string> _names = new ObservableCollection<string>()
{
"Isabel", "Michal"
};
public ObservableCollection<string> Names
{
get { return _names; }
set { _names = value; }
}
private ICollectionView View;
public MainWindow()
{
InitializeComponent();
ListBox.ItemsSource = Names;
View = CollectionViewSource.GetDefaultView(Names);
}
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
View.Filter = x => x.ToString().ToLower().Contains(((TextBox)sender).Text.ToLower());
}
There is no need to call CollectionViewSource.GetDefaultView(Names) in TextBoxChanged event since collectionView is retrieved once and keeps reference. Take a look here.
If it comes to MVVM pattern you are not supposed to use code-behind so instead of
<TextBox TextChanged="TextBoxBase_OnTextChanged"/>
you are supposed to have
<TextBox Text="{Binding FilterText}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding FilterListCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
RelayCommand
Related
So in my WPF app, I am trying to figure out how to make this scenario as MVVM:
Input text in a TextBox;
On a button press, retrieve the input and pass it to a function that is for a command
I have tried doing something along the lines of this:
private string creatureName;
public string CreatureName
{
get {
return creatureName;
}
set
{
if(!string.Equals(creatureName, value))
{
creatureName = value;
OnPropertyChanged("CreatureName");
}
}
}
and textbox like this:
<TextBox x:Name="CreatureNameBox" Text="{Binding Path=CreatureName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TextWrapping="NoWrap" FontFamily="Century Gothic" FontSize="16" Margin="150,0,150,16" MaxLines="1" Height="26" HorizontalAlignment="Stretch" VerticalAlignment="Center" Padding="5,3,5,3" MaxLength="100"/>
but it didn't work so I removed it.
Below is my code, if more code is needed let me know & I will update the ticket
TextBox:
<TextBox x:Name="CreatureNameBox" TextWrapping="NoWrap" FontFamily="Century Gothic" FontSize="16" Margin="150,0,150,16" MaxLines="1" Height="26" HorizontalAlignment="Stretch" VerticalAlignment="Center" Padding="5,3,5,3" MaxLength="100"/>
Button: Command is CreateNewCreature
<StackPanel>
<Button x:Name="CreateButton" Content="Create" FontWeight="Bold" FontFamily="Century Gothic" FontSize="18" Margin="10,3,10,0" Padding="0,5,0,5" Command="{Binding CreateNewCreature}" Height="34"/>
</StackPanel>
ViewModel: NewCreature() is where I want to pass the input value to as a string
namespace Creator.ViewModels
{
public class CreatureCreatorViewModel : ViewModelBase, INotifyPropertyChanged
{
public CreatureModel CreateNewCreature { get; set; }
public CreatureCreatorViewModel(NavigationStore navigationStore)
{
CreateNewCreature = new CreatureModel().NewCreature(*Retrieved TextBoxInput here*);
}
public CreatureCreatorViewModel()
{
}
}
}
Model:
namespace Creator.Models
{
public class CreatureModel : ISerializable
{
public string Name { get; set; }
public CreatureModel() { }
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Name", Name);
}
public CreatureModel NewCreature(string creatureName)
{
CreatureModel newCreature = new CreatureModel
{
Name = creatureName
};
using (FileStream fs = File.Open("[Censored Directory]/Data/TEST.5e", FileMode.Create))
{
Byte[] info = new UTF8Encoding(true).GetBytes("Name : " + newCreature.Name);
fs.Write(info);
}
return newCreature;
}
public CreatureModel(SerializationInfo info, StreamingContext context)
{
Name = (string)info.GetValue("Name", typeof(string));
}
}
}
For the simplest case.
ViewModel:
public class FunctionViewModel : BaseInpc
{
private int? _functionValue;
public int? FunctionValue { get => _functionValue; set => Set(ref _functionValue, value); }
private RelayCommand _functionCommand;
public RelayCommand FunctiontCommand => _functionCommand
?? (_functionCommand = new RelayCommand<string>(FunctionExecute));
private void FunctionExecute(string parameter)
{
//Some function is calculated here from received parameter.
//For example, just the length of the string.
FunctionValue = parameter?.Length;
}
}
XAML:
<UniformGrid DataContext="{DynamicResource viewModel}" Columns="2">
<FrameworkElement.Resources>
<local:FunctionViewModel x:Key="viewModel"/>
</FrameworkElement.Resources>
<TextBox x:Name="textBox" VerticalAlignment="Center" Margin="5" HorizontalContentAlignment="Center"/>
<Button Content="Calculate function" Padding="15 5" VerticalAlignment="Center"
Command="{Binding FunctiontCommand, Mode=OneWay}"
CommandParameter="{Binding Text, ElementName=textBox}"/>
<TextBlock Text="Function value:" HorizontalAlignment="Right" Margin="5"/>
<TextBox Text="{Binding FunctionValue}" IsReadOnly="True" VerticalAlignment="Top" Margin="5"
HorizontalContentAlignment="Center"/>
</UniformGrid>
The base classes from this answer were used: https://stackoverflow.com/questions/63174956/wpf-update-button-if-text-in-textbox-changes/63179286?r=SearchResults&s=1|42.4027#63179286
My first try at C#, WPF, and MVVM. I've looked at several answers and tutorials and just cannot seem to get this right.
I have a View a Model and a ViewModel file (Actually more, but trying to simplify). In the view I want to bind a textbox to a view model member. I also want to bind a button click to a view model method.
The delegate command for Login() works fine, but I can't seem to update the ID property in Acc.ID.
What would I need to change to be able to do both?
I understand I will probably need to implement the PropertyChanged event in the ViewModel instead of the Model...I just don't understand how.
What I can do is set the DataContextto user.Acc in the code behind to directly update the model, but then I obviously cannot bind to the Login() method.
ViewModel.cs
public class LoginVM
{
private ServerInterface _serverInterface;
private ICommand _loginCommand;
private EmployeeAccount _acc;
public ICommand LoginCommand
{
get { return _loginCommand; }
}
public LoginVM()
{
Acc = new EmployeeAccount();
_serverInterface = new ServerInterface();
_loginCommand = new DelegateCommand<String>(Login);
}
public EmployeeAccount Acc { get; set; }
private void Login(object state)
{
this.Acc.ID = _serverInterface.Encrypt(this.Acc.ID);
}
}
View.xaml.cs
public partial class LoginView : Window
{
public LoginView()
{
InitializeComponent();
BindInXaml();
}
private void BindInXaml()
{
base.DataContext = new LoginVM();
}
}
Model.cs
public class EmployeeAccount : INotifyPropertyChanged
{
String _id;
public EmployeeAccount()
{
ID = "5000";
Name = "George Washington";
isAdmin = true;
Pswd = "TheyDont";
}
public String ID
{
get { return _id; }
set
{
_id = value;
this.OnPropertyChanged("ID");
}
}
public string Name { get; set; }
public Boolean isAdmin { get; set; }
public string Pswd { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged(string propName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(
this, new PropertyChangedEventArgs(propName));
}
}
.xaml Put in only what matters really
<TextBox x:Name="txtLogInName" Margin="60,43,42,129" TextWrapping="Wrap" Text="{Binding Path=ID, UpdateSourceTrigger=PropertyChanged}" Width="120" Grid.Column="1" Grid.Row="1"/>
<Button x:Name="btnLogIn" Content="Log on" Command="{Binding LoginCommand}" Margin="160,151,10,23" Grid.Column="1" Grid.Row="1" RenderTransformOrigin="1.667,0.545"/>
<TextBlock x:Name="txtBlockPassReset" TextAlignment="Center" Grid.Row="1" Grid.Column="1" RenderTransformOrigin="1.348,1.765" Margin="60,101,42,78">
<Hyperlink>Reset Password</Hyperlink>
</TextBlock>
<PasswordBox x:Name="pswdBoxLoginPass" Grid.Column="1" HorizontalAlignment="Left" Margin="60,72,0,0" Grid.Row="1" VerticalAlignment="Top" Width="120" Password="Password"/>
Try changing your xaml from
<TextBox x:Name="txtLogInName" Margin="60,43,42,129" TextWrapping="Wrap"
Text="{Binding Path=ID, UpdateSourceTrigger=PropertyChanged}"
Width="120" Grid.Column="1" Grid.Row="1"/>
to
<TextBox x:Name="txtLogInName" Margin="60,43,42,129" TextWrapping="Wrap"
Text="{Binding Path=Acc.ID, UpdateSourceTrigger=PropertyChanged}"
Width="120" Grid.Column="1" Grid.Row="1" />
I want to generate ListItemBox using DataTemplate but items are not generating. Please guide me where is the mistake. I have following code in MainWindow.xaml.
<Window x:Class="Offline_Website_Downloader.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:bd="clr-namespace:Offline_Website_Downloader"
Title="Offline Website Downloader" Background="#f5f6f7" Height="500" Width="800"
WindowStartupLocation="CenterScreen">
<Window.Resources>
<bd:BindingController x:Key="BindingControllerKey" />
<DataTemplate x:Key="DownloadedWebsitesListBox">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" Width="Auto">
<TextBlock FontWeight="Bold" FontSize="18" Width="480">
<Hyperlink NavigateUri="http://google.com">
<Label Content="{Binding Path=WebsiteTitle}" />
</Hyperlink>
</TextBlock>
<TextBlock Width="132" TextAlignment="right">
<TextBlock Text="Remaining Time: "/>
<TextBlock Name="TimeRemaining" Text="js"/>
</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<ProgressBar Name="progress1" Maximum="100" Minimum="0" Value="30" Background="#FFF" Width="612" Height="10" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Left" Width="450">Status: <TextBlock Text="{Binding Path=Status}"/></TextBlock>
<TextBlock Width="162" TextAlignment="right">
<TextBlock Text="Downloading Speed: "/>
<TextBlock Name="DownloadingSpeed" Text="{Binding Path=DownloadingSpeed}"/>
</TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox Width="Auto"
Name="WebsiteList"
Grid.Column="1"
Grid.Row="2"
Grid.RowSpan="2"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource DownloadedWebsitesListBox}"
Margin="0,0,0,0">
</ListBox>
</Grid>
</window>
and MainWindow.xaml.cs
BindingController bc = new BindingController();
public MainWindow()
{
InitializeComponent();
bc.DownloadingSpeed = "40kb/s";
bc.WebsiteTitle = "WebsiteTitle";
bc.Status = "Downloading";
DataContext = bc;
}
and BindingController.cs
public class BindingController
{
public BindingController()
{
}
private string _WebsiteTitle;
public string WebsiteTitle
{
set { _WebsiteTitle = value; }
get { return _WebsiteTitle; }
}
private string _Status;
public string Status
{
set { _Status = value ; }
get { return _Status ; }
}
private string _DownloadStartDate;
public string DownloadStartDate
{
set { _DownloadStartDate = value; }
get { return _DownloadStartDate ; }
}
private string _DownloadingSpeed = "0 kb/s";
public string DownloadingSpeed
{
set { _DownloadingSpeed = value; }
get { return _DownloadingSpeed; }
}
}
Your problem is that you're binding a ListBox to an object that contains several properties, but really only represents a single object/state. The ListBox expects to display a list of items (i.e. IList, IBindingList, IEnumerable, ObservableCollection).
Assuming you want to display more than one download at a time, which I'm assuming given that you're using a ListBox, I would refactor the download properties into a separate class. You will also need to implement INotifyPropertyChanged on your properties so that when the values are changed, they will be shown in the UI.
public class Download : INotifyPropertyChanged
{
private string _WebsiteTitle;
public string WebsiteTitle
{
get { return _WebsiteTitle; }
set
{
if (_WebsiteTitle == value)
return;
_WebsiteTitle = value;
this.OnPropertyChanged("WebsiteTitle");
}
}
private string _Status;
public string Status
{
get { return _Status; }
set
{
if (_Status == value)
return;
_Status = value;
this.OnPropertyChanged("Status");
}
}
private string _DownloadStartDate;
public string DownloadStartDate
{
get { return _DownloadStartDate; }
set
{
if (_DownloadStartDate == value)
return;
_DownloadStartDate = value;
this.OnPropertyChanged("DownloadStartDate");
}
}
private string _DownloadingSpeed = "0 kb/s";
public string DownloadingSpeed
{
get { return _DownloadingSpeed; }
set
{
if (_DownloadingSpeed == value)
return;
_DownloadingSpeed = value;
this.OnPropertyChanged("DownloadingSpeed");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if(this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
The new BindingController:
public class BindingController
{
public BindingController()
{
this.Downloads = new ObservableCollection<Download>();
}
public ObservableCollection<Download> Downloads { get; private set; }
}
Setting up the bindings in XAML:
<ListBox Width="Auto"
Name="WebsiteList"
Grid.Column="1"
Grid.Row="2"
Grid.RowSpan="2"
ItemsSource="{Binding Downloads}"
ItemTemplate="{StaticResource DownloadedWebsitesListBox}"
Margin="0,0,0,0">
</ListBox>
Initializing the collection in MainWindow
Download download = new Download();
download.DownloadingSpeed = "40kb/s";
download.WebsiteTitle = "WebsiteTitle";
download.Status = "Downloading";
bc.Downloads.Add(download);
this.DataContext = bc;
I currently have the data for my application stored in an Azure Mobile Service SQL Database. I am pulling items from the database and displaying them in a List View. When a user clicks on an item in the list view they are then navigated to a new page that displays more details about the specific record from the database.
Main Page Code:
public class OSVersions
{
[JsonProperty(PropertyName = "id")]
public int id { get; set; }
[JsonProperty(PropertyName = "Version")]
public string Version { get; set; }
[JsonProperty(PropertyName = "Codename")]
public string Codename { get; set; }
[JsonProperty(PropertyName = "Publish")]
public bool Publish { get; set; }
[JsonProperty(PropertyName = "ReleaseDate")]
public DateTime ReleaseDate { get; set; }
[JsonProperty(PropertyName = "Changes")]
public string Changes { get; set; }
[JsonProperty(PropertyName = "Notes")]
public string Notes { get; set; }
}
public partial class OSMainVIew : PhoneApplicationPage
{
private MobileServiceCollection<OSVersions, OSVersions> items;
private IMobileServiceTable<OSVersions> osTable =
App.MobileService.GetTable<OSVersions>();
public OSMainVIew()
{
InitializeComponent();
}
private async void RefreshOSItems()
{
progressBar1.IsEnabled = true;
progressBar1.IsIndeterminate = true;
items = await osTable
.Where(OSItem => OSItem.Publish == true)
.ToCollectionAsync();
MainListBox.ItemsSource = items;
progressBar1.IsEnabled = false;
progressBar1.Visibility = System.Windows.Visibility.Collapsed;
progressBar1.IsIndeterminate = false;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
RefreshOSItems();
}
private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (MainListBox.SelectedIndex == -1)
return;
NavigationService.Navigate(new Uri("/ViewModels/OS/OSItemView.xaml?selectedItem=" + MainListBox.SelectedIndex, UriKind.Relative));
MainListBox.SelectedIndex = -1;
}
}
Item Page Code:
public partial class OSItemView : PhoneApplicationPage
{
private MobileServiceCollection<OSVersions, OSVersions> items;
private IMobileServiceTable<OSVersions> osTable =
App.MobileService.GetTable<OSVersions>();
public OSItemView()
{
InitializeComponent();
if ((Application.Current as App).IsTrial)
{
//textBlock1.Text = "Change Log available in full version only!";
//textBlock2.Visibility = System.Windows.Visibility.Collapsed;
}
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
string selectedIndex = "";
int buildID;
int idValue;
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
//Start progressBar
progressBar1.IsEnabled = true;
progressBar1.IsIndeterminate = true;
//Convert selectedIndex -> buildID
idValue = Convert.ToInt32(selectedIndex);
buildID = idValue + 1;
/* buildID = idValue + 1 becuase on OSMainView
* Items stored in the ListBox are each even an index number
* The first number is '0'
* This is a problem because the first IDNumber in the Database is '1'
* This isn't the best way to handle this, becuase even though the id field is an auto-increamental field,
* sometimes values are skipped and rows are deleted.
*/
//Query database
items = await osTable
.Where(OSItem => OSItem.id == buildID)
.ToCollectionAsync();
MainListBox.ItemsSource = items;
//End progressBar
progressBar1.IsEnabled = false;
progressBar1.Visibility = System.Windows.Visibility.Collapsed;
progressBar1.IsIndeterminate = false;
}
}
}
Items Page XAML Code:
<Grid x:Name="ContentPanel" Margin="10,97,12,0" Grid.RowSpan="2">
<ListBox x:Name="MainListBox" Margin="10,-35,-12,0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,0" Width="432" Height="*">
<TextBlock TextWrapping="Wrap" Text="{Binding Version}" Style=" {StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="Notes" FontFamily="Segoe WP Bold" Foreground="{StaticResource PhoneAccentBrush}" Height="30" HorizontalAlignment="Left" Margin="0,1,0,0" Name="textBlock3" Padding="0" VerticalAlignment="Top" Width="444" />
<TextBlock x:Name="notesText" Text="{Binding Notes}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Height="180" VerticalAlignment="Top" HorizontalAlignment="Stretch" FontFamily="Segoe WP SemiLight" Margin="0" Width="455"/>
<TextBlock Text="Change Log" Height="30" HorizontalAlignment="Left" Margin="0,222,0,0" Name="textBlock1" VerticalAlignment="Top" FontFamily="Segoe WP Bold" Foreground="{StaticResource PhoneAccentBrush}" Width="444" Padding="0" />
<TextBlock Name="textBlock2" Text="{Binding Changes}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FontFamily="Segoe WP SemiLight" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
My problem occurs when MainListBox.ItemsSource = items; is executed.
The application quits without any error codes.
Any ideas?
The problem had to due with the Height of the StackPanel being set to '*'. After removing that, the problem was solved.
am showing list of movie as a panorama for my windows phone 7 app. on click on each movie am showing the movie details,cast.
the movie details , cast am showing as a pivot control. movie details works fine
But when i got to show cast as , it doesnt work. i have list of cast objects. and am binding the source to a listbox in the cast pivot control , but it doesnt show any data. Please help me. below are the classes i have used. Thank you
MainViewModel.cs
public class MainViewModel
{
public ObservableCollection<ItemViewModel> MovieItems { get; set; }
}
ItemViewModel.cs
public class ItemViewModel : INotifyPropertyChanged
{
private string _title;
public string _Title
{
get { return _title; }
set
{
if (value != _title)
{
_title = value;
NotifyPropertyChanged("title");
}
}
}
private ObservableCollection<Cast> _cast;
public ObservableCollection<Cast> _Cast
{
get { return _cast; }
set
{
if (value != _cast)
{
_cast = value;
NotifyPropertyChanged("Cast");
}
}
}
..........
}
Cast.cs
public class Cast
{
public string name { get; set; }
public string imagesource { get; set; }
public Cast(string _name, string _imagesource)
{
this.imagesource = _imagesource;
this.name = _name;
}
}
for each movie i have a list of cast objects
MovieModel.cs
App.Model.MovieItems.Add(
new ItemViewModel()
{
_Title = data["title"].ToString(),
_Cast=casObs,
........
}
);
moviedetails.xaml
<ListBox Name="ListBox" Margin="0,0,-12,0" ItemsSource="{Binding _Cast}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="78">
<Canvas>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="120,5,60,3" Text="{Binding name}" TextWrapping="Wrap" FontSize="32" Style="{StaticResource PhoneTextNormalStyle}"/>
<Image Height="90" HorizontalAlignment="Left" Margin="12,10,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="90" Source="{Binding imagesource}" />
</Canvas>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Replace
NotifyPropertyChanged("title");
to
NotifyPropertyChanged("_Title");
And
NotifyPropertyChanged("Cast");
to
NotifyPropertyChanged("_Cast");
Hope it's help.
apply converter inbetween, where you need to return ImageSource/BitmapImage, instead of string