Reworked to properly bind objects

UWPTest
Brian Lima 8 years ago
parent 3faa422c8e
commit 18d659a6b9

Binary file not shown.

@ -1,14 +0,0 @@
<UserControl x:Class="UWPHook.Game"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:UWPHook"
mc:Ignorable="d" d:DesignWidth="300" Height="100">
<Grid>
<TextBlock x:Name="textBlock" Margin="10,10,10,0" TextWrapping="Wrap" Text="{Binding game_full_name}" VerticalAlignment="Top" FontWeight="Bold" FontSize="24"/>
<TextBlock x:Name="textBlock1" Margin="10,74,10,-6" TextWrapping="Wrap" Text="{Binding game_path}" VerticalAlignment="Top"/>
<TextBlock x:Name="textBlock2" HorizontalAlignment="Left" Margin="10,53,0,0" TextWrapping="Wrap" Text="{Binding game_alias}" VerticalAlignment="Top"/>
</Grid>
</UserControl>

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace UWPHook
{
/// <summary>
/// Interaction logic for Game.xaml
/// </summary>
public partial class Game : UserControl
{
public Game()
{
InitializeComponent();
}
}
}

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
@ -9,9 +10,61 @@ using System.Windows.Data;
namespace UWPHook
{
class GameModel
public class GameModel
{
public GameModel()
{
games = new ObservableCollection<Game>();
}
private ObservableCollection<Game> _games;
public ObservableCollection<Game> games
{
get { return _games; }
set { _games = value; }
}
public void Add(Game game)
{
this.games.Add(game);
}
public string game_alias { get; set; }
public string game_path { get; set; }
}
public class Game:INotifyPropertyChanged
{
private string _game_alias;
public string game_alias
{
get { return _game_alias; }
set { _game_alias = value; }
}
private string _game_path;
public string game_path
{
get { return _game_path; }
set { _game_path = value; }
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string Obj)
{
if (PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(Obj));
}
}
}
}

@ -20,7 +20,6 @@
<ListView x:Name="listView" RenderTransformOrigin="0.496,0.409">
<ListView.View>
<GridView>
<GridViewColumn Width="75" Header="alias" DisplayMemberBinding="{Binding game_alias}"/>
<GridViewColumn Width="300" Header="Name" DisplayMemberBinding="{Binding game_path}"/>
</GridView>

@ -20,8 +20,7 @@ namespace UWPHook
/// </summary>
public partial class MainWindow : Window
{
List<GameModel> games;
GameModel games;
public MainWindow()
{
InitializeComponent();
@ -30,23 +29,24 @@ namespace UWPHook
{
}
games = new List<GameModel>();
for (int i = 0; i < 10; i++)
{
games.Add(new GameModel { game_alias = "sajufhsaduifhuisdsdgbuigduisaguidsguisaguiasguidasg", game_path = "sajufhsaduifhuisdsdgbuigduisaguidsguisaguiasguidasgx" });
}
// games = new List<GameModel>();
// for (int i = 0; i < 10; i++)
// {
// games.Add(new GameModel { game_alias = "sajufhsaduifhuisdsdgbuigduisaguidsguisaguiasguidasg", game_path = "sajufhsaduifhuisdsdgbuigduisaguidsguisaguiasguidasgx" });
// }
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
listView.ItemsSource = games;
games = new GameModel();
listView.ItemsSource = games.games;
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
games.Add(new GameModel { game_alias = alias_textBox.Text, game_path = path_textBox.Text });
games.Add(new Game{ game_alias = alias_textBox.Text, game_path = path_textBox.Text });
}
}
}

@ -55,10 +55,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="GameControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -67,9 +63,6 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="GameControl.xaml.cs">
<DependentUpon>GameControl.xaml</DependentUpon>
</Compile>
<Compile Include="GameModel.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>

Binary file not shown.

Binary file not shown.

@ -1,111 +0,0 @@
#pragma checksum "..\..\GameControl.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "B94A3B2C8698E37FA30B383750547435"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using UWPHook;
namespace UWPHook {
/// <summary>
/// Game
/// </summary>
public partial class Game : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
#line 9 "..\..\GameControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock textBlock;
#line default
#line hidden
#line 10 "..\..\GameControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock textBlock1;
#line default
#line hidden
#line 11 "..\..\GameControl.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock textBlock2;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/UWPHook;component/gamecontrol.xaml", System.UriKind.Relative);
#line 1 "..\..\GameControl.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.textBlock = ((System.Windows.Controls.TextBlock)(target));
return;
case 2:
this.textBlock1 = ((System.Windows.Controls.TextBlock)(target));
return;
case 3:
this.textBlock2 = ((System.Windows.Controls.TextBlock)(target));
return;
}
this._contentLoaded = true;
}
}
}

Binary file not shown.

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "52D5E2F31147D8DFFD5BB4DC42FD9D44"
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "EB1C3AA91BED862DBD7F69AABACA045D"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -49,7 +49,7 @@ namespace UWPHook {
#line hidden
#line 37 "..\..\MainWindow.xaml"
#line 36 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button addButton;
@ -57,7 +57,7 @@ namespace UWPHook {
#line hidden
#line 38 "..\..\MainWindow.xaml"
#line 37 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox alias_textBox;
@ -65,7 +65,7 @@ namespace UWPHook {
#line hidden
#line 39 "..\..\MainWindow.xaml"
#line 38 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label label;
@ -73,7 +73,7 @@ namespace UWPHook {
#line hidden
#line 40 "..\..\MainWindow.xaml"
#line 39 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox path_textBox;
@ -81,7 +81,7 @@ namespace UWPHook {
#line hidden
#line 41 "..\..\MainWindow.xaml"
#line 40 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label label_Copy;
@ -89,7 +89,7 @@ namespace UWPHook {
#line hidden
#line 42 "..\..\MainWindow.xaml"
#line 41 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button helpButton;
@ -140,7 +140,7 @@ namespace UWPHook {
case 3:
this.addButton = ((System.Windows.Controls.Button)(target));
#line 37 "..\..\MainWindow.xaml"
#line 36 "..\..\MainWindow.xaml"
this.addButton.Click += new System.Windows.RoutedEventHandler(this.addButton_Click);
#line default

@ -1,4 +1,4 @@
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "52D5E2F31147D8DFFD5BB4DC42FD9D44"
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "EB1C3AA91BED862DBD7F69AABACA045D"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -49,7 +49,7 @@ namespace UWPHook {
#line hidden
#line 37 "..\..\MainWindow.xaml"
#line 36 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button addButton;
@ -57,7 +57,7 @@ namespace UWPHook {
#line hidden
#line 38 "..\..\MainWindow.xaml"
#line 37 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox alias_textBox;
@ -65,7 +65,7 @@ namespace UWPHook {
#line hidden
#line 39 "..\..\MainWindow.xaml"
#line 38 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label label;
@ -73,7 +73,7 @@ namespace UWPHook {
#line hidden
#line 40 "..\..\MainWindow.xaml"
#line 39 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox path_textBox;
@ -81,7 +81,7 @@ namespace UWPHook {
#line hidden
#line 41 "..\..\MainWindow.xaml"
#line 40 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Label label_Copy;
@ -89,7 +89,7 @@ namespace UWPHook {
#line hidden
#line 42 "..\..\MainWindow.xaml"
#line 41 "..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button helpButton;
@ -140,7 +140,7 @@ namespace UWPHook {
case 3:
this.addButton = ((System.Windows.Controls.Button)(target));
#line 37 "..\..\MainWindow.xaml"
#line 36 "..\..\MainWindow.xaml"
this.addButton.Click += new System.Windows.RoutedEventHandler(this.addButton_Click);
#line default

@ -12,5 +12,3 @@ c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\obj\Debug\U
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\obj\Debug\UWPHook.csproj.GenerateResource.Cache
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\obj\Debug\UWPHook.exe
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\obj\Debug\UWPHook.pdb
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\obj\Debug\GameControl.g.cs
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\obj\Debug\GameControl.baml

Binary file not shown.

Binary file not shown.

@ -10,11 +10,11 @@ none
false
DEBUG;TRACE
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\App.xaml
2-1868972323
11151548125
7740677473
6-470569544
131569487696
GameControl.xaml;MainWindow.xaml;
MainWindow.xaml;
False

@ -10,11 +10,11 @@ none
false
DEBUG;TRACE
c:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\App.xaml
2-1868972323
11151548125
11-644645457
10-1855892474
131569487696
GameControl.xaml;MainWindow.xaml;
MainWindow.xaml;
True
False

@ -1,4 +0,0 @@

Fc:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\MainWindow.xaml;;

@ -1,5 +1,4 @@

Fc:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\GameControl.xaml;;
Fc:\users\brian\documents\visual studio 2015\Projects\UWPHook\UWPHook\MainWindow.xaml;;

Loading…
Cancel
Save