L
labjac
Guest
Hallo
I hit a point where we cannot continue and think we might need to go back to Windows Forms due to the complexity of what we trying to achieve with the WPF layout.
We followed the MVVM patterns and our data is returned as a collection of objects in a BindableCollection. But we need to determine a specific row and column to insert the object properties, (also could be variable amount of objects).
Each object represents a location for operators in a warehouse enviroment, (The object also holds the information on which row and columns this data needs to be inserted. (Meaning we will have x,y grid with OrderNr as the text value, and backColour of the cell based on another property in a single object..
Done a small diagram which hopefully explains a bit better.
And how the final layout should look, only different is we need to add the CellColour as a property.
namespace WCS_WPF_FrontEnd.ViewModel
{
public class PigeonDataSetModelView
{
public BindableCollection <PigeonCellStatusModel> WallGrid { get; }
public PigeonDataSetModelView()
{
var sqlTable = new DataTable();
var sqlDataTable = new tb_ProdPigeonStatusSql();
int rowCounter = 0;
sqlTable = sqlDataTable.SelectAllRecords();
List<PigeonCellStatusModel> wallComplete = new List<PigeonCellStatusModel>();
foreach (DataRow dr in sqlTable.Rows)
{
var singleTempObject = new PigeonCellStatusModel(sqlTable.Rows[rowCounter]);
wallComplete.Add(singleTempObject);
rowCounter++;
}
WallGrid = new BindableCollection<PigeonCellStatusModel>(wallComplete);
}
}
}
Above the ModelViewClass that got all the objects in a BindableCollection.
namespace WCS_WPF_FrontEnd
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void SettingsLabel_MouseDown(object sender, MouseButtonEventArgs e)
{
var pigeonStuff = new PigeonDataSetModelView();
WallGrid.ItemsSource = pigeonStuff.WallGrid;
}
Code behind the XAML which populates the itemsource.
But in windows form we could have created a foreach loop to place text in specific cells, eg.
Data.Rows[0][1] = would put a value from the list. (pigeonStuff.WallGrid[0].OrderNumber)
And similar for backcolour etc.
I'm very lost so we get our data in a collection, how to manipulate the rows and columns and which is best approach or should we consider Winforms again?
labjac
Continue reading...
I hit a point where we cannot continue and think we might need to go back to Windows Forms due to the complexity of what we trying to achieve with the WPF layout.
We followed the MVVM patterns and our data is returned as a collection of objects in a BindableCollection. But we need to determine a specific row and column to insert the object properties, (also could be variable amount of objects).
Each object represents a location for operators in a warehouse enviroment, (The object also holds the information on which row and columns this data needs to be inserted. (Meaning we will have x,y grid with OrderNr as the text value, and backColour of the cell based on another property in a single object..
Done a small diagram which hopefully explains a bit better.
And how the final layout should look, only different is we need to add the CellColour as a property.
namespace WCS_WPF_FrontEnd.ViewModel
{
public class PigeonDataSetModelView
{
public BindableCollection <PigeonCellStatusModel> WallGrid { get; }
public PigeonDataSetModelView()
{
var sqlTable = new DataTable();
var sqlDataTable = new tb_ProdPigeonStatusSql();
int rowCounter = 0;
sqlTable = sqlDataTable.SelectAllRecords();
List<PigeonCellStatusModel> wallComplete = new List<PigeonCellStatusModel>();
foreach (DataRow dr in sqlTable.Rows)
{
var singleTempObject = new PigeonCellStatusModel(sqlTable.Rows[rowCounter]);
wallComplete.Add(singleTempObject);
rowCounter++;
}
WallGrid = new BindableCollection<PigeonCellStatusModel>(wallComplete);
}
}
}
Above the ModelViewClass that got all the objects in a BindableCollection.
namespace WCS_WPF_FrontEnd
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void SettingsLabel_MouseDown(object sender, MouseButtonEventArgs e)
{
var pigeonStuff = new PigeonDataSetModelView();
WallGrid.ItemsSource = pigeonStuff.WallGrid;
}
Code behind the XAML which populates the itemsource.
But in windows form we could have created a foreach loop to place text in specific cells, eg.
Data.Rows[0][1] = would put a value from the list. (pigeonStuff.WallGrid[0].OrderNumber)
And similar for backcolour etc.
I'm very lost so we get our data in a collection, how to manipulate the rows and columns and which is best approach or should we consider Winforms again?
labjac
Continue reading...