I am trying to create a ListBox view for show data, and I want it to contain a ListBox with a datatemplate for 2 columns \"Product ID & Product Barcode\"
I want
I have created DataTemplate like this:
private DataTemplate getDataTemplate()
{
DataTemplate retVal = null;
String markup = String.Empty;
markup = "";
markup += "";
markup += " ";
markup += " ";
markup += " ";
retVal = (DataTemplate)XamlReader.Load(markup);
return retVal;
}
...and then call this method where you need it (like OnApplyTemplate)
this.ContentTemplate = getDataTemplate();
NOTE : You may have to change the "xmlns" for WPF, because this example is taken from one of my Silverlight projects. But the idea is the same.