├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── res
├── CustomTheme_01.png
├── CustomTheme_02.png
├── DataGridCellStyle_FocusTrigger.gif
├── DelayedProgressDialogExample.gif
├── DynamicDataExample.png
├── FilterExample.png
├── HamburgerMenuAutoOpenClose.gif
├── HamburgerMenuCompositeCollection.png
└── ListViewWithDetail.png
└── src
└── Tims.Wpf-Examples
├── BlinkingButton
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── BlinkingButton.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── ViewModel.cs
├── ComboBoxAndDataTableExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── ComboBoxAndDataTableExample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── Model
│ └── ViewModel.cs
├── CustomThemesExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── CustomThemesExample.csproj
├── MainWindow.xaml
└── MainWindow.xaml.cs
├── DataGridCellStyleExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── DataGridCellStyleExample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── ViewModel.cs
├── DelayShowProgressExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── DelayShowProgressExample.csproj
├── MainWindow.xaml
└── MainWindow.xaml.cs
├── DynamicDataExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── DynamicDataExample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── Model
│ ├── ListItem.cs
│ └── MainViewModel.cs
├── FilterDataGridExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── FilterDataGridExample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Person.cs
└── ViewModel.cs
├── HamburgerMenuAutoPaneOpening
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── HamburgerMenuAutoPaneOpening.csproj
├── MainWindow.xaml
└── MainWindow.xaml.cs
├── HamburgerMenuCompositeExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── CustomDll
│ └── TimsWpfControls.dll
├── HamburgerMenuCompositeExample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── Model
│ ├── ContentTemplateSelector.cs
│ ├── FilepathToFilenameConverter.cs
│ └── ViewModel.cs
├── IntersectTwoLists
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── IntersectTwoLists.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── Model
│ ├── Dog.cs
│ ├── Human.cs
│ ├── Pair.cs
│ └── ViewModel.cs
├── ListViewDetailsExample
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── ExampleWithDetail.cs
├── ListViewDetailsExample.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
└── ViewModel.cs
├── Tims.Wpf.Examples.sln
├── WindowInDifferentThread
├── App.xaml
├── App.xaml.cs
├── AssemblyInfo.cs
├── ChildWindow.xaml
├── ChildWindow.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── SharedViewModel.cs
└── WindowInDifferentThread.csproj
└── testEmbed
├── App.config
├── App.xaml
├── App.xaml.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── packages.config
├── testEmbed.csproj
└── testEmbed.sln
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # JustCode is a .NET coding add-in
131 | .JustCode
132 |
133 | # TeamCity is a build add-in
134 | _TeamCity*
135 |
136 | # DotCover is a Code Coverage Tool
137 | *.dotCover
138 |
139 | # AxoCover is a Code Coverage Tool
140 | .axoCover/*
141 | !.axoCover/settings.json
142 |
143 | # Visual Studio code coverage results
144 | *.coverage
145 | *.coveragexml
146 |
147 | # NCrunch
148 | _NCrunch_*
149 | .*crunch*.local.xml
150 | nCrunchTemp_*
151 |
152 | # MightyMoose
153 | *.mm.*
154 | AutoTest.Net/
155 |
156 | # Web workbench (sass)
157 | .sass-cache/
158 |
159 | # Installshield output folder
160 | [Ee]xpress/
161 |
162 | # DocProject is a documentation generator add-in
163 | DocProject/buildhelp/
164 | DocProject/Help/*.HxT
165 | DocProject/Help/*.HxC
166 | DocProject/Help/*.hhc
167 | DocProject/Help/*.hhk
168 | DocProject/Help/*.hhp
169 | DocProject/Help/Html2
170 | DocProject/Help/html
171 |
172 | # Click-Once directory
173 | publish/
174 |
175 | # Publish Web Output
176 | *.[Pp]ublish.xml
177 | *.azurePubxml
178 | # Note: Comment the next line if you want to checkin your web deploy settings,
179 | # but database connection strings (with potential passwords) will be unencrypted
180 | *.pubxml
181 | *.publishproj
182 |
183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
184 | # checkin your Azure Web App publish settings, but sensitive information contained
185 | # in these scripts will be unencrypted
186 | PublishScripts/
187 |
188 | # NuGet Packages
189 | *.nupkg
190 | # NuGet Symbol Packages
191 | *.snupkg
192 | # The packages folder can be ignored because of Package Restore
193 | **/[Pp]ackages/*
194 | # except build/, which is used as an MSBuild target.
195 | !**/[Pp]ackages/build/
196 | # Uncomment if necessary however generally it will be regenerated when needed
197 | #!**/[Pp]ackages/repositories.config
198 | # NuGet v3's project.json files produces more ignorable files
199 | *.nuget.props
200 | *.nuget.targets
201 |
202 | # Microsoft Azure Build Output
203 | csx/
204 | *.build.csdef
205 |
206 | # Microsoft Azure Emulator
207 | ecf/
208 | rcf/
209 |
210 | # Windows Store app package directories and files
211 | AppPackages/
212 | BundleArtifacts/
213 | Package.StoreAssociation.xml
214 | _pkginfo.txt
215 | *.appx
216 | *.appxbundle
217 | *.appxupload
218 |
219 | # Visual Studio cache files
220 | # files ending in .cache can be ignored
221 | *.[Cc]ache
222 | # but keep track of directories ending in .cache
223 | !?*.[Cc]ache/
224 |
225 | # Others
226 | ClientBin/
227 | ~$*
228 | *~
229 | *.dbmdl
230 | *.dbproj.schemaview
231 | *.jfm
232 | *.pfx
233 | *.publishsettings
234 | orleans.codegen.cs
235 |
236 | # Including strong name files can present a security risk
237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
238 | #*.snk
239 |
240 | # Since there are multiple workflows, uncomment next line to ignore bower_components
241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
242 | #bower_components/
243 |
244 | # RIA/Silverlight projects
245 | Generated_Code/
246 |
247 | # Backup & report files from converting an old project file
248 | # to a newer Visual Studio version. Backup files are not needed,
249 | # because we have git ;-)
250 | _UpgradeReport_Files/
251 | Backup*/
252 | UpgradeLog*.XML
253 | UpgradeLog*.htm
254 | ServiceFabricBackup/
255 | *.rptproj.bak
256 |
257 | # SQL Server files
258 | *.mdf
259 | *.ldf
260 | *.ndf
261 |
262 | # Business Intelligence projects
263 | *.rdl.data
264 | *.bim.layout
265 | *.bim_*.settings
266 | *.rptproj.rsuser
267 | *- [Bb]ackup.rdl
268 | *- [Bb]ackup ([0-9]).rdl
269 | *- [Bb]ackup ([0-9][0-9]).rdl
270 |
271 | # Microsoft Fakes
272 | FakesAssemblies/
273 |
274 | # GhostDoc plugin setting file
275 | *.GhostDoc.xml
276 |
277 | # Node.js Tools for Visual Studio
278 | .ntvs_analysis.dat
279 | node_modules/
280 |
281 | # Visual Studio 6 build log
282 | *.plg
283 |
284 | # Visual Studio 6 workspace options file
285 | *.opt
286 |
287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
288 | *.vbw
289 |
290 | # Visual Studio LightSwitch build output
291 | **/*.HTMLClient/GeneratedArtifacts
292 | **/*.DesktopClient/GeneratedArtifacts
293 | **/*.DesktopClient/ModelManifest.xml
294 | **/*.Server/GeneratedArtifacts
295 | **/*.Server/ModelManifest.xml
296 | _Pvt_Extensions
297 |
298 | # Paket dependency manager
299 | .paket/paket.exe
300 | paket-files/
301 |
302 | # FAKE - F# Make
303 | .fake/
304 |
305 | # CodeRush personal settings
306 | .cr/personal
307 |
308 | # Python Tools for Visual Studio (PTVS)
309 | __pycache__/
310 | *.pyc
311 |
312 | # Cake - Uncomment if you are using it
313 | # tools/**
314 | # !tools/packages.config
315 |
316 | # Tabs Studio
317 | *.tss
318 |
319 | # Telerik's JustMock configuration file
320 | *.jmconfig
321 |
322 | # BizTalk build output
323 | *.btp.cs
324 | *.btm.cs
325 | *.odx.cs
326 | *.xsd.cs
327 |
328 | # OpenCover UI analysis results
329 | OpenCover/
330 |
331 | # Azure Stream Analytics local run output
332 | ASALocalRun/
333 |
334 | # MSBuild Binary and Structured Log
335 | *.binlog
336 |
337 | # NVidia Nsight GPU debugger configuration file
338 | *.nvuser
339 |
340 | # MFractors (Xamarin productivity tool) working folder
341 | .mfractor/
342 |
343 | # Local History for Visual Studio
344 | .localhistory/
345 |
346 | # BeatPulse healthcheck temp database
347 | healthchecksdb
348 |
349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
350 | MigrationBackup/
351 |
352 | # Ionide (cross platform F# VS Code tools) working folder
353 | .ionide/
354 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Tim
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tims.Wpf.Examples
2 |
3 | Just some code examples.
4 |
5 | -------
6 |
7 | ## HamburgerMenu sample using CompositeCollection
8 | This sample demonstrates a few advanced possibilities of the cool [MahApps HamburgerMenu](https://mahapps.com).
9 |
10 | ### Features
11 | - Uses `CompositeCollection` to show normal `HamburgerMenuItem` together with a dynamic `OservableCollection`
12 | - Uses a custom `DataTemplateSelector` to provide different apperance for the items
13 | - Uses different `DataTemplates`
14 | - Uses `Binding` to show/hide some items
15 |
16 | ### Preview
17 | 
18 |
19 | --------------------------------------------------------------
20 |
21 | ## HamburgerMenu with Pane that opens automatically on MouseOver
22 |
23 | Attention: This sample should only show that it is possible to do it with a custom `ControlTemplate`. It may be a bad UX / UI. Please think about it before you implement this in your App.
24 |
25 | ### Features
26 | - `HamburgerMenu` opens when the user moves the cursor over the items.
27 |
28 | ### Preview
29 | 
30 |
31 | --------------------------------------------------------------
32 |
33 | ## Custom Style for DataGridCell with Trigger
34 |
35 | ### Features
36 | - A `Button` shows up when the `DataGridCell` becomes the focus
37 | - For now the cell will start editing mode when you click the button
38 |
39 | ### Preview
40 | 
41 |
42 | --------------------------------------------------------------
43 |
44 | ## Delayed ProgressDialog
45 |
46 | ### Features
47 | - Set time when the dialog should be shown in seconds
48 | - Set time to wait in seconds
49 | - `ProgressDialog` will appear after the given time, if needed.
50 |
51 | ### Preview
52 | 
53 |
54 | ### Source
55 | [https://github.com/timunie/MahApps.Metro.Examples/tree/master/src/MahApps.Metro.Examples/DelayShowProgressExample](https://github.com/timunie/MahApps.Metro.Examples/tree/master/src/MahApps.Metro.Examples/DelayShowProgressExample)
56 |
57 |
58 | --------------------------------------------------------------
59 |
60 | ## Filter Example
61 | ### Features
62 | - Filter a list by different filter options
63 | - match persons first name
64 | - and or match persons last name
65 | - and or match persons age
66 | - Filter updates automatically
67 |
68 | ### Preview
69 | 
70 |
71 | *Shows all persons with first name or last name contain >su< and age between 20 and 80*
72 | ### Source
73 | [https://github.com/timunie/MahApps.Metro.Examples/tree/master/src/MahApps.Metro.Examples/FilterDataGridExample](https://github.com/timunie/MahApps.Metro.Examples/tree/master/src/MahApps.Metro.Examples/FilterDataGridExample)
74 |
75 | ------------------
76 | ## ListView with Details
77 | ### Features
78 | Opens a detail view only for the selected item.
79 |
80 | ### Preview
81 | 
82 |
83 | ### Source
84 | https://github.com/timunie/MahApps.Metro.Examples/tree/master/src/MahApps.Metro.Examples/ListViewDetailsExample
85 |
86 | ------------------------------
87 |
88 | ## Custom Themes Example
89 |
90 | ### Features
91 | - Change the current theme via custom accent and base theme
92 | - Apply additionaly `DynamicResources` to provide your own appereance
93 |
94 | ### How it works
95 | 1. In your App.xaml or any other `Resoruces` section add:
96 | ```xaml
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | ```
113 |
114 | 2. when you change the `Theme` change also the `Brush`:
115 | ```c#
116 | public static void SetAppTheme(string baseTheme, Color accent)
117 | {
118 | var theme = new Theme("MyTheme",
119 | "MyTheme",
120 | baseTheme ?? ThemeManager.BaseColorLightConst,
121 | accent.ToString(),
122 | accent,
123 | new SolidColorBrush(accent),
124 | true,
125 | false);
126 |
127 | var HsvAccent = new HSVColor(accent);
128 |
129 | // Change the Bursh here. You may also want to Freeze it.
130 | var newBrush = new SolidColorBrush(new HSVColor(HsvAccent.Hue + 180,
131 | HsvAccent.Saturation,
132 | HsvAccent.Value).ToColor());
133 |
134 | newBrush.Freeze();
135 | App.Current.Resources["My.Brushes.Complementary"] = newBrush;
136 |
137 | ThemeManager.Current.ChangeTheme(App.Current, theme);
138 | }
139 | ```
140 |
141 | 3. Use the new Resource anywhere:
142 | ```xaml
143 |
144 | ```
145 |
146 | ### Preview
147 | 
148 |
149 | 
150 |
151 | ### Source
152 | [CustomThemesExample](src/Tims.Wpf-Examples/CustomThemesExample)
153 |
154 | --------
155 |
156 | ## Window in a different Thread
157 |
158 | ### Features
159 | - Open Window in different Thread
160 | - Moving or resizing the MainWindow will also affect the child
161 |
162 | ### How it works
163 | - Using a ViewModel to store the position and react on changes
164 | - Use the `Dispatcher.InvokeAsync` in order to update child window from other thread
165 |
166 | ### Source
167 | [WindowInDifferentThread](src/Tims.Wpf-Examples/WindowInDifferentThread)
168 |
169 |
170 | ------
171 |
172 | ## Long List with DynamicData (ReacticeUI) and Filtering
173 |
174 | ### Features
175 | - Loads 5,000 items or more in a very short time < 1s
176 | - Filter the long list during typing
177 | - Test different methods
178 |
179 | ### How it works
180 | - Using DynamicData: https://www.reactiveui.net/docs/handbook/collections/
181 |
182 | ### Preview
183 | 
184 |
185 | ### Source
186 | [DynamicData](src/Tims.Wpf-Examples/DynamicDataExample)
--------------------------------------------------------------------------------
/res/CustomTheme_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/CustomTheme_01.png
--------------------------------------------------------------------------------
/res/CustomTheme_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/CustomTheme_02.png
--------------------------------------------------------------------------------
/res/DataGridCellStyle_FocusTrigger.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/DataGridCellStyle_FocusTrigger.gif
--------------------------------------------------------------------------------
/res/DelayedProgressDialogExample.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/DelayedProgressDialogExample.gif
--------------------------------------------------------------------------------
/res/DynamicDataExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/DynamicDataExample.png
--------------------------------------------------------------------------------
/res/FilterExample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/FilterExample.png
--------------------------------------------------------------------------------
/res/HamburgerMenuAutoOpenClose.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/HamburgerMenuAutoOpenClose.gif
--------------------------------------------------------------------------------
/res/HamburgerMenuCompositeCollection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/HamburgerMenuCompositeCollection.png
--------------------------------------------------------------------------------
/res/ListViewWithDetail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/res/ListViewWithDetail.png
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace BlinkingButton
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/BlinkingButton.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace BlinkingButton
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/BlinkingButton/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Text;
5 |
6 | namespace BlinkingButton
7 | {
8 | public class ViewModel : INotifyPropertyChanged
9 | {
10 | public event PropertyChangedEventHandler PropertyChanged;
11 |
12 | public void RaisePropertyChanged(string Name)
13 | {
14 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(Name));
15 | }
16 |
17 | private bool _DoBlink;
18 | public bool DoBlink
19 | {
20 | get { return _DoBlink; }
21 | set { _DoBlink = value; RaisePropertyChanged(nameof(DoBlink)); }
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace ComboBoxAndDataTableExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/ComboBoxAndDataTableExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net5.0-windows
6 | true
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | Binding to ObserableCollection:
22 |
23 |
24 | Binding to First Column of DataTable:
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace ComboBoxAndDataTableExample
17 | {
18 | ///
19 | /// Interaction logic for MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ComboBoxAndDataTableExample/Model/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ComboBoxAndDataTableExample.Model
10 | {
11 | public class ViewModel
12 | {
13 | public ViewModel()
14 | {
15 | People.Columns.Add("First Name", typeof(string));
16 | People.Columns.Add("Last Name", typeof(string));
17 | People.Columns.Add("Age", typeof(int));
18 | }
19 |
20 | public ObservableCollection Animals { get; } = new ObservableCollection()
21 | {
22 | "Dog",
23 | "Cat",
24 | "Ant"
25 | };
26 |
27 | public DataTable People { get; } = new DataTable();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/CustomThemesExample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/CustomThemesExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using ControlzEx.Theming;
2 | using MahApps.Metro.Controls;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Configuration;
6 | using System.Data;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Media;
11 |
12 | namespace CustomThemesExample
13 | {
14 | ///
15 | /// Interaction logic for App.xaml
16 | ///
17 | public partial class App : Application
18 | {
19 | protected override void OnStartup(StartupEventArgs e)
20 | {
21 | base.OnStartup(e);
22 |
23 | SetAppTheme("Light", Colors.DarkBlue);
24 | }
25 |
26 | public static void SetAppTheme(string baseTheme, Color accent)
27 | {
28 | var theme = new Theme("MyTheme",
29 | "MyTheme",
30 | baseTheme ?? ThemeManager.BaseColorLightConst,
31 | accent.ToString(),
32 | accent,
33 | new SolidColorBrush(accent),
34 | true,
35 | false);
36 |
37 | var HsvAccent = new HSVColor(accent);
38 |
39 | var newBrush = new SolidColorBrush(new HSVColor(HsvAccent.Hue + 180,
40 | HsvAccent.Saturation,
41 | HsvAccent.Value).ToColor());
42 |
43 | newBrush.Freeze();
44 | App.Current.Resources["My.Brushes.Complementary"] = newBrush;
45 | ;
46 |
47 | ThemeManager.Current.ChangeTheme(App.Current, theme);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/CustomThemesExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/CustomThemesExample/CustomThemesExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net5.0-windows
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/CustomThemesExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 | Light
18 | Dark
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |
36 |
42 |
46 |
47 |
48 |
54 |
58 |
59 |
60 |
66 |
70 |
71 |
72 |
78 |
82 |
83 |
84 |
90 |
94 |
95 |
96 |
102 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/CustomThemesExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using ControlzEx.Theming;
2 | using MahApps.Metro.Controls;
3 | using MahApps.Metro.Theming;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Input;
14 | using System.Windows.Media;
15 | using System.Windows.Media.Imaging;
16 | using System.Windows.Navigation;
17 | using System.Windows.Shapes;
18 |
19 | namespace CustomThemesExample
20 | {
21 | ///
22 | /// Interaction logic for MainWindow.xaml
23 | ///
24 | public partial class MainWindow : MetroWindow
25 | {
26 | public MainWindow()
27 | {
28 | InitializeComponent();
29 | }
30 |
31 | private void ButtonApplyTheme_Click(object sender, RoutedEventArgs e)
32 | {
33 | App.SetAppTheme(ComboBoxBaseTheme.SelectedItem as string, ColorPickerAccent.SelectedColor.Value);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace DataGridCellStyleExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/DataGridCellStyleExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ..\..\..\..\TimsWpfControls\TimsWpfControls\TimsWpfControls\bin\Release\netcoreapp3.1\TimsWpfControls.dll
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
24 |
27 |
28 |
29 |
30 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace DataGridCellStyleExample
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DataGridCellStyleExample/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Text;
5 | using TimsWpfControls.Converter;
6 | using TimsWpfControls.Model;
7 |
8 | namespace DataGridCellStyleExample
9 | {
10 |
11 | public class Person : BaseClass
12 | {
13 | public Person(string firstName, string lastName, int age)
14 | {
15 | Name = lastName;
16 | FirstName = firstName;
17 | Age = age;
18 | }
19 |
20 | private string _Name;
21 | public string Name
22 | {
23 | get { return _Name; }
24 | set { _Name = value; RaisePropertyChanged(nameof(Name)); }
25 | }
26 |
27 | private string _FirstName;
28 | public string FirstName
29 | {
30 | get { return _FirstName; }
31 | set { _FirstName = value; RaisePropertyChanged(nameof(FirstName)); }
32 | }
33 |
34 | private int _Age;
35 | public int Age
36 | {
37 | get { return _Age; }
38 | set { _Age = value; RaisePropertyChanged(nameof(Age)); }
39 | }
40 |
41 | }
42 |
43 | public class ViewModel : BaseClass
44 | {
45 | public ObservableCollection People { get; } = new ObservableCollection()
46 | {
47 | new Person("Tim", "U.", 32),
48 | new Person("Tom", "Tommy", 45),
49 | new Person("Tick", "Tack", 10),
50 | new Person("Trick", "Track", 20)
51 | };
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DelayShowProgressExample/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DelayShowProgressExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace DelayShowProgressExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DelayShowProgressExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DelayShowProgressExample/DelayShowProgressExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DelayShowProgressExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DelayShowProgressExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using MahApps.Metro.Controls.Dialogs;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Input;
14 | using System.Windows.Media;
15 | using System.Windows.Media.Imaging;
16 | using System.Windows.Navigation;
17 | using System.Windows.Shapes;
18 | using System.Windows.Threading;
19 |
20 | namespace DelayShowProgressExample
21 | {
22 | ///
23 | /// Interaction logic for MainWindow.xaml
24 | ///
25 | public partial class MainWindow : MetroWindow
26 | {
27 | public MainWindow()
28 | {
29 | InitializeComponent();
30 |
31 | // Setup the time
32 | beginShowProgressTimer = new DispatcherTimer(DispatcherPriority.Input, Dispatcher);
33 | beginShowProgressTimer.Tick += BeginShowProgressTimer_Tick;
34 | }
35 |
36 | private async void BeginShowProgressTimer_Tick(object sender, EventArgs e)
37 | {
38 | beginShowProgressTimer.Stop();
39 | AppendText("timer stopped");
40 | dialogController = await this.ShowProgressAsync("Hi", "Here I am :-)");
41 | AppendText("progress shown");
42 | dialogController.SetIndeterminate();
43 | }
44 |
45 | private DispatcherTimer beginShowProgressTimer;
46 | private ProgressDialogController dialogController;
47 | private async void Button_Click(object sender, RoutedEventArgs e)
48 | {
49 | ClearText();
50 |
51 | beginShowProgressTimer.Interval = TimeSpan.FromSeconds(NUD_ShowProgressDelay.Value ?? 0);
52 |
53 | AppendText($"set timer to {NUD_ShowProgressDelay.Value} second(s)");
54 |
55 | beginShowProgressTimer.Start();
56 |
57 | AppendText("timer started");
58 |
59 | // Run our Process
60 | AppendText($"process started and will run {NUD_TaskDuration.Value} Second(s)");
61 | await Task.Delay(TimeSpan.FromSeconds(NUD_TaskDuration.Value ?? 1));
62 | AppendText("process finished");
63 |
64 | // Esure we stop the timer
65 | beginShowProgressTimer.Stop();
66 | AppendText("timer stopped");
67 |
68 | // If we have the dialog close it.
69 | if (dialogController != null)
70 | {
71 | await dialogController.CloseAsync();
72 | AppendText("dialog closed");
73 | dialogController = null;
74 | AppendText("dialog set to 'null'");
75 | }
76 | }
77 |
78 | private void AppendText(string text)
79 | {
80 | var action = new Action(() => TXT_Output.AppendText($"{DateTime.Now}: {text}{Environment.NewLine}"));
81 | Dispatcher.BeginInvoke(DispatcherPriority.Send, action);
82 | }
83 |
84 | private void ClearText()
85 | {
86 | var action = new Action(() => TXT_Output.SetCurrentValue(TextBox.TextProperty, null));
87 | Dispatcher.BeginInvoke(DispatcherPriority.Send, action);
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace DynamicDataExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/DynamicDataExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net5.0-windows
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using DynamicDataExample.Model;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Controls;
10 | using System.Windows.Data;
11 | using System.Windows.Documents;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 | using System.Windows.Media.Imaging;
15 | using System.Windows.Navigation;
16 | using System.Windows.Shapes;
17 |
18 | namespace DynamicDataExample
19 | {
20 | ///
21 | /// Interaction logic for MainWindow.xaml
22 | ///
23 | public partial class MainWindow : Window
24 | {
25 | MainViewModel ViewModel => DataContext as MainViewModel;
26 |
27 | public MainWindow()
28 | {
29 | InitializeComponent();
30 | }
31 | private void Method_01_Click(object sender, RoutedEventArgs e)
32 | {
33 | Stopwatch stopwatch = new Stopwatch();
34 |
35 | stopwatch.Start();
36 | ViewModel.CreateTestData(false);
37 |
38 | stopwatch.Stop();
39 |
40 | MessageBox.Show($"The update took {stopwatch.ElapsedMilliseconds} ms");
41 | }
42 |
43 | private void Method_02_Click(object sender, RoutedEventArgs e)
44 | {
45 | Stopwatch stopwatch = new Stopwatch();
46 |
47 | stopwatch.Start();
48 |
49 | ViewModel.CreateTestData(true);
50 |
51 | stopwatch.Stop();
52 |
53 | MessageBox.Show($"The update took {stopwatch.ElapsedMilliseconds} ms");
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/Model/ListItem.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace DynamicDataExample.Model
9 | {
10 | public class ListItem : ReactiveObject
11 | {
12 | private int _ID;
13 | public int ID
14 | {
15 | get { return _ID; }
16 | set { this.RaiseAndSetIfChanged(ref _ID, value); }
17 | }
18 |
19 |
20 |
21 | private string _Content;
22 |
23 | ///
24 | /// Any content to display.
25 | ///
26 | public string Content
27 | {
28 | get { return _Content; }
29 | set { this.RaiseAndSetIfChanged(ref _Content, value); }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/DynamicDataExample/Model/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using DynamicData;
2 | using DynamicData.Binding;
3 | using ReactiveUI;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Collections.ObjectModel;
7 | using System.Diagnostics;
8 | using System.Linq;
9 | using System.Reactive.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 | using System.Windows;
13 |
14 | namespace DynamicDataExample.Model
15 | {
16 | public class MainViewModel : ReactiveObject
17 | {
18 | public MainViewModel()
19 | {
20 | var filterPredicate = this.WhenAnyValue(x => x.Filter)
21 | .Throttle(TimeSpan.FromMilliseconds(250), RxApp.MainThreadScheduler)
22 | .DistinctUntilChanged()
23 | .Select(listItemFilter);
24 |
25 | _listItemsCache
26 | .Connect()
27 | .Sort(SortExpressionComparer.Ascending(x => x.ID))
28 | .ObserveOn(RxApp.MainThreadScheduler)
29 | .AutoRefresh(x => x.Content, TimeSpan.FromMilliseconds(200))
30 | .Filter(filterPredicate)
31 | .Bind(out _ListItems)
32 | .Subscribe();
33 |
34 | CreateTestData(false);
35 |
36 |
37 | }
38 |
39 | private readonly SourceList _listItemsCache = new SourceList();
40 |
41 | private readonly ReadOnlyObservableCollection _ListItems;
42 | public ReadOnlyObservableCollection ListItems => _ListItems;
43 |
44 |
45 | private string _Filter;
46 |
47 | ///
48 | /// A filter to search for an item.
49 | ///
50 | public string Filter
51 | {
52 | get { return _Filter; }
53 | set { this.RaiseAndSetIfChanged(ref _Filter, value); }
54 | }
55 |
56 | Func listItemFilter(string text) => listItem =>
57 | {
58 | return string.IsNullOrEmpty(text) || listItem.Content.Contains(text, StringComparison.OrdinalIgnoreCase);
59 | };
60 |
61 | public void CreateTestData(bool fastInsert = true)
62 | {
63 | _listItemsCache.Clear();
64 |
65 | if (fastInsert)
66 | {
67 | _listItemsCache.Edit((x) =>
68 | {
69 | x.Clear();
70 | for (int i = 0; i < ItemsToGenerate; i++)
71 | {
72 | x.Add(new ListItem() { ID = i, Content = $"Some Content {i:N0}" });
73 | }
74 | });
75 | }
76 | else
77 | {
78 | for (int i = 0; i < ItemsToGenerate; i++)
79 | {
80 | _listItemsCache.Add(new ListItem() { ID = i, Content = $"Some Content {i:N0}" });
81 | }
82 | }
83 |
84 | }
85 |
86 |
87 | private int _ItemsToGenerate = 5000;
88 |
89 | ///
90 | /// No of Items to generate
91 | ///
92 | public int ItemsToGenerate
93 | {
94 | get { return _ItemsToGenerate; }
95 | set { this.RaiseAndSetIfChanged(ref _ItemsToGenerate, value); }
96 | }
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace FilterDataGridExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/FilterDataGridExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace FilterDataGridExample
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/Person.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace FilterDataGridExample
6 | {
7 | public class Person
8 | {
9 | public Person(string firstName, string lastName, int age)
10 | {
11 | FirstName = firstName;
12 | LastName = lastName;
13 | Age = age;
14 | }
15 |
16 | public string FirstName { get; }
17 | public string LastName { get; }
18 | public int Age { get; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/FilterDataGridExample/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.ComponentModel;
5 | using System.Text;
6 | using System.Windows.Data;
7 | using System.Windows.Input;
8 |
9 | namespace FilterDataGridExample
10 | {
11 | public class ViewModel : INotifyPropertyChanged
12 | {
13 | public event PropertyChangedEventHandler PropertyChanged;
14 | public void OnPropertyChanged(string PropertyName)
15 | {
16 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
17 | }
18 |
19 | public ViewModel()
20 | {
21 | FilteredView = CollectionViewSource.GetDefaultView(People);
22 | FilteredView.Filter = IsFilterOK;
23 | }
24 |
25 | public ObservableCollection People { get; } = new ObservableCollection(
26 | new[]
27 | {
28 | new Person("Quinn", "Montes", 82),
29 | new Person("Lila", "Baldwin", 73),
30 | new Person("Patrice", "Wallace", 97),
31 | new Person("Stanton", "York", 36),
32 | new Person("Kerry", "Gates", 9),
33 | new Person("Coleen", "Hahn", 38),
34 | new Person("Suzette", "Orr", 75),
35 | new Person("Rey", "Cobb", 70),
36 | new Person("Josephine", "Turner", 87),
37 | new Person("Noel", "Christensen", 69),
38 | new Person("Maryellen", "Roach", 15),
39 | new Person("Adriana", "Carney", 41),
40 | new Person("Ferdinand", "Riggs", 50),
41 | new Person("Donnie", "Moyer", 77),
42 | new Person("Beth", "Frey", 26),
43 | new Person("Kristina", "Matthews", 2),
44 | new Person("Santo", "Shaffer", 21),
45 | new Person("Rosalie", "Esparza", 83),
46 | new Person("Lynn", "Mccormick", 25),
47 | new Person("Mary", "Walls", 25),
48 | new Person("Kelley", "Bentley", 40),
49 | new Person("Howard", "Chen", 40),
50 | new Person("Elbert", "Mckee", 84),
51 | new Person("Elsie", "Walton", 22),
52 | new Person("Gladys", "Oneill", 50),
53 | new Person("Felix", "Carey", 45),
54 | new Person("Rosalind", "Cooley", 76),
55 | new Person("Willie", "Johnston", 15),
56 | new Person("Kristine", "Quinn", 78),
57 | new Person("Beverley", "Gaines", 2),
58 | new Person("Robby", "Soto", 57),
59 | new Person("Caroline", "Austin", 48),
60 | new Person("Augustus", "Alvarado", 12),
61 | new Person("Alissa", "Proctor", 49),
62 | new Person("Darron", "Saunders", 13),
63 | new Person("Lester", "Bass", 42),
64 | new Person("Ernest", "Howard", 82),
65 | new Person("Mona", "Nash", 96),
66 | new Person("Jolene", "Benson", 33),
67 | new Person("Cyrus", "Cochran", 73),
68 | new Person("Danielle", "Guerrero", 64),
69 | new Person("Laverne", "Moreno", 92),
70 | new Person("Lina", "Huber", 72),
71 | new Person("Nicolas", "Shannon", 90),
72 | new Person("Antone", "Mays", 30),
73 | new Person("Bridgett", "Winters", 75),
74 | new Person("Betty", "Brennan", 26),
75 | new Person("Davis", "Sexton", 45),
76 | new Person("Sheldon", "Alvarez", 26),
77 | new Person("Rolland", "Mcbride", 72),
78 | new Person("Chuck", "Henry", 64),
79 | new Person("Merle", "Armstrong", 42),
80 | new Person("Francisco", "Rowland", 2),
81 | new Person("Georgette", "Singh", 52),
82 | new Person("Luella", "Moss", 90),
83 | new Person("Jeramy", "Mcfarland", 65),
84 | new Person("Prince", "Clay", 49),
85 | new Person("Ken", "Pena", 16),
86 | new Person("Evelyn", "Fox", 39),
87 | new Person("Chelsea", "Thomas", 12),
88 | new Person("Nicholas", "Wallace", 32),
89 | new Person("Geraldo", "Jensen", 77),
90 | new Person("Yolanda", "Haley", 89),
91 | new Person("Aisha", "Le", 0),
92 | new Person("Melanie", "Roach", 77),
93 | new Person("Sean", "Middleton", 93),
94 | new Person("Foster", "Hardin", 82),
95 | new Person("Jillian", "Oliver", 64),
96 | new Person("Leon", "Koch", 21),
97 | new Person("Elton", "Ball", 65),
98 | new Person("Myles", "Aguirre", 62),
99 | new Person("Pierre", "Newton", 66),
100 | new Person("Wilbert", "Gaines", 12),
101 | new Person("Johnny", "Wiggins", 17),
102 | new Person("Mohammed", "Pratt", 55),
103 | new Person("Jerri", "Luna", 13),
104 | new Person("Elden", "Wright", 35),
105 | new Person("Traci", "Reed", 72),
106 | new Person("Ronda", "Ellis", 87),
107 | new Person("Roxanne", "Briggs", 44),
108 | new Person("Garret", "Gilmore", 35),
109 | new Person("Maria", "Hanna", 38),
110 | new Person("Hazel", "Weiss", 4),
111 | new Person("Florentino", "Davies", 74),
112 | new Person("Wilburn", "Valenzuela", 37),
113 | new Person("Hope", "Curry", 33),
114 | new Person("Elvia", "Garrison", 89),
115 | new Person("Jamie", "Stevens", 28),
116 | new Person("Dwayne", "Jackson", 24),
117 | new Person("Lynette", "Donaldson", 9),
118 | new Person("Adam", "Vang", 98),
119 | new Person("Cornelia", "Berg", 20),
120 | new Person("Clement", "Pennington", 84),
121 | new Person("Asa", "Kerr", 97),
122 | new Person("Jeff", "Valencia", 95),
123 | new Person("Jackson", "Kemp", 65),
124 | new Person("Alta", "Mccormick", 96),
125 | new Person("Chas", "Nolan", 83),
126 | new Person("Patti", "Little", 95),
127 | new Person("Tracie", "Combs", 56),
128 | new Person("Arthur", "Gates", 13),
129 | new Person("Carl", "Peters", 33),
130 | new Person("Sylvia", "Gibbs", 7),
131 | new Person("Davis", "Shields", 35),
132 | new Person("Ines", "Baxter", 35),
133 | new Person("Leslie", "Lowery", 68),
134 | new Person("Pete", "Moody", 67),
135 | new Person("Paris", "Dominguez", 1),
136 | new Person("Walton", "Klein", 54),
137 | new Person("Lori", "Branch", 40),
138 | new Person("Santiago", "Noble", 22),
139 | new Person("Fanny", "Francis", 70),
140 | new Person("Luis", "Booker", 2),
141 | new Person("Randi", "Mills", 57),
142 | new Person("Donovan", "Sexton", 21),
143 | new Person("Johnnie", "Watts", 37),
144 | new Person("Elroy", "Paul", 35),
145 | new Person("Luz", "Bryan", 1),
146 | new Person("Bonnie", "Braun", 65),
147 | new Person("Claudio", "Grant", 14),
148 | new Person("Fermin", "Joyce", 35),
149 | new Person("Lyle", "Benjamin", 12),
150 | new Person("Jerold", "Schmidt", 22),
151 | new Person("Alfreda", "Chase", 53),
152 | new Person("Lindsey", "Griffin", 84),
153 | new Person("Melinda", "Rhodes", 86),
154 | new Person("Latisha", "Knapp", 78),
155 | new Person("Deanna", "Ferguson", 3),
156 | new Person("Tim", "Duke", 52),
157 | new Person("Dexter", "Moore", 86),
158 | new Person("Leandro", "Lamb", 97),
159 | new Person("Vicky", "Larson", 31),
160 | new Person("Wendy", "Bates", 50),
161 | new Person("Dorothea", "Martinez", 88),
162 | new Person("Jared", "Lopez", 98),
163 | new Person("Benny", "Hoffman", 92),
164 | new Person("Deborah", "Saunders", 12),
165 | new Person("Mary", "Decker", 30),
166 | new Person("Luella", "Frye", 81),
167 | new Person("Veronica", "Silva", 29),
168 | new Person("Benton", "Pearson", 68),
169 | new Person("Maynard", "Woodard", 39),
170 | new Person("Dora", "Fox", 24),
171 | new Person("Fredric", "Benson", 93),
172 | new Person("Celia", "Robbins", 12),
173 | new Person("Sallie", "Randolph", 39),
174 | new Person("Stan", "Morrow", 21),
175 | new Person("Tyson", "Cruz", 92),
176 | new Person("Elma", "Macdonald", 17),
177 | new Person("Dawn", "Mayo", 77),
178 | new Person("Cheri", "Washington", 86),
179 | new Person("Bernadette", "Mcclain", 48),
180 | new Person("Claudette", "Rangel", 60),
181 | new Person("Bradley", "Kline", 32),
182 | new Person("Annie", "Richards", 32),
183 | new Person("Genaro", "Holden", 86),
184 | new Person("Cornell", "Guerra", 15),
185 | new Person("Sid", "Alvarez", 58),
186 | new Person("Cyrus", "Woodard", 30),
187 | new Person("Colin", "Graham", 88),
188 | new Person("Imelda", "Kelly", 15),
189 | new Person("Tory", "Carter", 79),
190 | new Person("Lesley", "Koch", 49),
191 | new Person("Danny", "Pennington", 55),
192 | new Person("Wayne", "Allison", 43),
193 | new Person("Gertrude", "Nelson", 27),
194 | new Person("Bennie", "Snyder", 60),
195 | new Person("Elias", "Dawson", 86),
196 | new Person("Fanny", "Parsons", 8),
197 | new Person("Ericka", "Heath", 44),
198 | new Person("Bret", "Daugherty", 40),
199 | new Person("Pearlie", "Barrera", 58),
200 | new Person("Shirley", "Johnston", 36),
201 | new Person("Ty", "Sharp", 74),
202 | new Person("Elva", "Lowe", 49),
203 | new Person("Dwayne", "Owen", 76),
204 | new Person("Cheryl", "Macdonald", 59),
205 | new Person("Kieth", "Hancock", 71),
206 | new Person("Alex", "Murray", 7),
207 | new Person("Carlos", "Mckenzie", 18),
208 | new Person("Frances", "Cowan", 2),
209 | new Person("Cherie", "Rasmussen", 20),
210 | new Person("Armando", "Delgado", 53),
211 | new Person("Eugenia", "Proctor", 88),
212 | new Person("Kris", "Norman", 89),
213 | new Person("Tameka", "Cortez", 7),
214 | new Person("Chauncey", "Fischer", 45),
215 | new Person("Arden", "Hansen", 90),
216 | new Person("Hubert", "Gaines", 62),
217 | new Person("Damion", "Marsh", 57),
218 | new Person("Mollie", "Buckley", 50),
219 | new Person("Adalberto", "Bishop", 95),
220 | new Person("Kathleen", "Vaughn", 23),
221 | new Person("Marisol", "Boyle", 25),
222 | new Person("Emily", "Stanton", 55),
223 | new Person("Brianna", "Mcguire", 45),
224 | new Person("Ambrose", "Snow", 68),
225 | new Person("Tabatha", "Bruce", 5),
226 | new Person("Casandra", "Avery", 21),
227 | new Person("Fran", "Pena", 21)
228 | });
229 |
230 | public ICollectionView FilteredView { get; }
231 |
232 |
233 | bool _FilterFirstName = true;
234 | public bool FilterFirstName
235 | {
236 | get { return _FilterFirstName; }
237 | set
238 | {
239 | _FilterFirstName = value;
240 | OnPropertyChanged(nameof(FilterFirstName));
241 | FilteredView.Refresh();
242 | }
243 | }
244 |
245 | bool _FilterLastName = true;
246 | public bool FilterLastName
247 | {
248 | get { return _FilterLastName; }
249 | set
250 | {
251 | _FilterLastName = value;
252 | OnPropertyChanged(nameof(FilterLastName));
253 | FilteredView.Refresh();
254 | }
255 | }
256 |
257 | string _FilterText = "Mo";
258 | public string FilterText
259 | {
260 | get { return _FilterText; }
261 | set
262 | {
263 | _FilterText = value;
264 | OnPropertyChanged(nameof(FilterText));
265 | FilteredView.Refresh();
266 | }
267 | }
268 |
269 |
270 | int? _MinAge;
271 | public int? MinAge
272 | {
273 | get { return _MinAge; }
274 | set
275 | {
276 | _MinAge = value;
277 | OnPropertyChanged(nameof(MinAge));
278 | FilteredView.Refresh();
279 | }
280 | }
281 |
282 | int? _MaxAge;
283 | public int? MaxAge
284 | {
285 | get { return _MaxAge; }
286 | set
287 | {
288 | _MaxAge = value;
289 | OnPropertyChanged(nameof(MaxAge));
290 | FilteredView.Refresh();
291 | }
292 | }
293 |
294 | bool IsFilterOK (object item)
295 | {
296 | bool accepted = false;
297 | if (item is Person person)
298 | {
299 | // check the Name
300 | if (string.IsNullOrWhiteSpace(FilterText))
301 | accepted |= true;
302 | else if (!string.IsNullOrWhiteSpace(FilterText) && FilterFirstName && person.FirstName.Contains(FilterText, StringComparison.OrdinalIgnoreCase))
303 | accepted |= true;
304 | else if (!string.IsNullOrWhiteSpace(FilterText) && FilterLastName && person.LastName.Contains(FilterText, StringComparison.OrdinalIgnoreCase))
305 | accepted |= true;
306 |
307 | // check the Age
308 | if (MinAge != null && MaxAge != null)
309 | accepted &= person.Age >= MinAge && person.Age <= MaxAge;
310 | else if (MinAge != null)
311 | accepted &= person.Age >= MinAge;
312 | else if (MaxAge != null)
313 | accepted &= person.Age <= MaxAge;
314 | }
315 |
316 | return accepted;
317 | }
318 | }
319 | }
320 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuAutoPaneOpening/App.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
154 |
155 |
156 |
157 |
158 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuAutoPaneOpening/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace HamburgerMenuAutoPaneOpening
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuAutoPaneOpening/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuAutoPaneOpening/HamburgerMenuAutoPaneOpening.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ..\..\..\..\TimsWpfControls\TimsWpfControls\TimsWpfControls\bin\Release\netcoreapp3.1\TimsWpfControls.dll
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuAutoPaneOpening/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuAutoPaneOpening/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace HamburgerMenuAutoPaneOpening
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
23 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace HamburgerMenuCompositeExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/CustomDll/TimsWpfControls.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timunie/Tims.Wpf.Examples/75bf770bd7c35ef49c96f9ac57aaef05f23099df/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/CustomDll/TimsWpfControls.dll
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/HamburgerMenuCompositeExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | CustomDll\TimsWpfControls.dll
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
48 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
72 |
73 |
74 |
75 |
76 |
82 |
86 |
87 |
88 |
89 |
90 |
91 |
94 |
95 |
96 |
97 |
98 |
104 |
105 |
108 |
109 |
110 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
145 |
149 |
150 |
151 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
181 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using HamburgerMenuCompositeExample.Model;
2 | using MahApps.Metro.Controls;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Input;
14 | using System.Windows.Media;
15 | using System.Windows.Media.Imaging;
16 | using System.Windows.Navigation;
17 |
18 | namespace HamburgerMenuCompositeExample
19 | {
20 | ///
21 | /// Interaction logic for MainWindow.xaml
22 | ///
23 | public partial class MainWindow : MetroWindow
24 | {
25 | ViewModel ViewModel => DataContext as ViewModel;
26 |
27 | public MainWindow()
28 | {
29 | InitializeComponent();
30 | }
31 |
32 | private void ListView_Drop(object sender, DragEventArgs e)
33 | {
34 | if (e.Data.GetDataPresent(DataFormats.FileDrop))
35 | {
36 | // Note that you can have more than one file.
37 | string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
38 |
39 | foreach (var file in files)
40 | {
41 | var fileAtribute = File.GetAttributes(file);
42 | if (fileAtribute == FileAttributes.Directory)
43 | {
44 | ViewModel.AddFolder(file);
45 | }
46 | else
47 | {
48 | if (ViewModel.AllowedImageFiles.Contains("*" + Path.GetExtension(file)))
49 | {
50 | ViewModel.Images.Add(file);
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
57 | private void ListView_PreviewDragOver(object sender, DragEventArgs e)
58 | {
59 | e.Effects = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
60 | }
61 |
62 |
63 | private void myHamburgerMenu_ItemClick(object sender, ItemClickEventArgs args)
64 | {
65 | if (args.ClickedItem is HamburgerMenuItem menuItem && !(menuItem.Command is null))
66 | {
67 | // Mark us as handled so we don't change the selection
68 | args.Handled = true;
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/Model/ContentTemplateSelector.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 |
8 | namespace HamburgerMenuCompositeExample.Model
9 | {
10 | public class ContentTemplateSelector : DataTemplateSelector
11 | {
12 | public DataTemplate ImageTemplate { get; set; }
13 | public DataTemplate HamburgerMenuItemTemplate { get; set; }
14 |
15 |
16 | public override DataTemplate SelectTemplate(object item, DependencyObject container)
17 | {
18 | if (item is HamburgerMenuIconItem)
19 | {
20 | return HamburgerMenuItemTemplate;
21 | }
22 |
23 | else if (item is string)
24 | {
25 | return ImageTemplate;
26 | }
27 | return base.SelectTemplate(item, container);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/Model/FilepathToFilenameConverter.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Converters;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Globalization;
5 | using System.IO;
6 | using System.Text;
7 |
8 | namespace HamburgerMenuCompositeExample.Model
9 | {
10 | public class FilepathToFilenameConverter : MarkupConverter
11 | {
12 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13 | {
14 | if (value is string path)
15 | {
16 | return Path.GetFileNameWithoutExtension(path);
17 | }
18 | return null;
19 | }
20 |
21 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22 | {
23 | throw new NotImplementedException();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/HamburgerMenuCompositeExample/Model/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using Microsoft.WindowsAPICodePack.Dialogs;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Controls;
11 | using TimsWpfControls.Model;
12 |
13 | namespace HamburgerMenuCompositeExample.Model
14 | {
15 | public class ViewModel : BaseClass
16 | {
17 |
18 | public ViewModel()
19 | {
20 | Images.CollectionChanged += Images_CollectionChanged;
21 | AddFolder(Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures));
22 | }
23 |
24 |
25 | internal static readonly string[] AllowedImageFiles =
26 | {
27 | "*.jpg",
28 | "*.jpeg",
29 | "*.gif",
30 | "*.png",
31 | "*.tiff"
32 | };
33 |
34 | public ObservableCollection Images { get; } = new ObservableCollection();
35 |
36 | public bool HasImages => Images.Count > 0;
37 |
38 | private void Images_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
39 | {
40 | RaisePropertyChanged(nameof(HasImages));
41 | }
42 |
43 |
44 | private RelayCommand _AddImagesCommand;
45 | public RelayCommand AddImagesCommand
46 | {
47 | get { return _AddImagesCommand ??= new RelayCommand((param) => AddImages()); }
48 | }
49 |
50 | private void AddImages()
51 | {
52 | var dlg = new OpenFileDialog
53 | {
54 | Filter = $"Image Files ({string.Join(";", AllowedImageFiles)})|{string.Join(";", AllowedImageFiles)}|All files (*.*)|*.*",
55 | Multiselect = true,
56 | InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
57 | };
58 |
59 | if (dlg.ShowDialog() == true)
60 | {
61 | foreach (var file in dlg.FileNames)
62 | {
63 | Images.Add(file);
64 | }
65 | }
66 | }
67 |
68 | private RelayCommand _AddFolderCommand;
69 | public RelayCommand AddFolderCommand
70 | {
71 | get { return _AddFolderCommand ??= new RelayCommand((param) => AddFolder(null)); }
72 | }
73 |
74 | internal async void AddFolder(string FolderName)
75 | {
76 | if (string.IsNullOrEmpty(FolderName))
77 | {
78 | var dialog = new CommonOpenFileDialog
79 | {
80 | IsFolderPicker = true,
81 | InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
82 | };
83 |
84 | if (dialog.ShowDialog()== CommonFileDialogResult.Ok)
85 | {
86 | FolderName = dialog.FileName;
87 | }
88 | }
89 | var images = new List();
90 |
91 | await Task.Run(() =>
92 | {
93 | if (Directory.Exists(FolderName ?? string.Empty))
94 | {
95 | foreach (var file in Directory.GetFiles(FolderName, "", SearchOption.AllDirectories))
96 | {
97 | if (AllowedImageFiles.Contains("*" + Path.GetExtension(file)))
98 | {
99 | images.Add(file);
100 | }
101 | }
102 | }
103 | });
104 |
105 | foreach (var item in images)
106 | {
107 | Images.Add(item);
108 | }
109 |
110 | }
111 |
112 | private RelayCommand _ClearCollectionCommand;
113 | public RelayCommand ClearCollectionCommand
114 | {
115 | get { return _ClearCollectionCommand ??= new RelayCommand((param) => Clear()); }
116 | set { _ClearCollectionCommand = value; RaisePropertyChanged(nameof(ClearCollectionCommand)); }
117 | }
118 |
119 | private void Clear()
120 | {
121 | Images.Clear();
122 | }
123 |
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace IntersectTwoLists
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/IntersectTwoLists.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ..\..\..\..\TimsWpfControls\TimsWpfControls\TimsWpfControls\bin\Release\netcoreapp3.1\TimsWpfControls.dll
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace IntersectTwoLists
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/Model/Dog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Media;
5 | using TimsWpfControls.Model;
6 |
7 | namespace IntersectTwoLists.Model
8 | {
9 | public class Dog : BaseClass
10 | {
11 | public Dog()
12 | {
13 |
14 | }
15 |
16 | public Dog(string name, Color? colorOfLine)
17 | {
18 | Name = name;
19 | ColorOfLine = colorOfLine;
20 | }
21 |
22 | private string _Name;
23 | public string Name
24 | {
25 | get { return _Name; }
26 | set { _Name = value; RaisePropertyChanged(nameof(Name)); }
27 | }
28 |
29 | private Color? _ColorOfLine;
30 | public Color? ColorOfLine
31 | {
32 | get { return _ColorOfLine; }
33 | set { _ColorOfLine = value; RaisePropertyChanged(nameof(ColorOfLine)); }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/Model/Human.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Media;
5 | using TimsWpfControls.Model;
6 |
7 | namespace IntersectTwoLists.Model
8 | {
9 | public class Human : BaseClass
10 | {
11 | public Human()
12 | {
13 |
14 | }
15 |
16 | public Human(string name, Color? colorOfLine)
17 | {
18 | Name = name;
19 | ColorOfLine = colorOfLine;
20 | }
21 |
22 | private string _Name;
23 | public string Name
24 | {
25 | get { return _Name; }
26 | set { _Name = value; RaisePropertyChanged(nameof(Name)); }
27 | }
28 |
29 | private Color? _ColorOfLine;
30 | public Color? ColorOfLine
31 | {
32 | get { return _ColorOfLine; }
33 | set { _ColorOfLine = value; RaisePropertyChanged(nameof(ColorOfLine)); }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/Model/Pair.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using TimsWpfControls.Model;
5 |
6 | namespace IntersectTwoLists.Model
7 | {
8 | public class Pair : BaseClass
9 | {
10 | private Human _Human;
11 | public Human Human
12 | {
13 | get { return _Human; }
14 | set { _Human = value; RaisePropertyChanged(nameof(Human)); }
15 | }
16 |
17 | private Dog _Dog;
18 | public Dog Dog
19 | {
20 | get { return _Dog; }
21 | set { _Dog = value; RaisePropertyChanged(nameof(Dog)); }
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/IntersectTwoLists/Model/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Windows.Media;
8 | using TimsWpfControls.Model;
9 |
10 | namespace IntersectTwoLists.Model
11 | {
12 | public class ViewModel : BaseClass
13 | {
14 | public ViewModel()
15 | {
16 | Humen.CollectionChanged += Any_CollectionChanged;
17 | Dogs.CollectionChanged += Any_CollectionChanged;
18 |
19 | Humen.Add(new Human("Jake", Colors.Green));
20 | Humen.Add(new Human("Tim", Colors.Blue));
21 | Humen.Add(new Human("Lisa", Colors.Pink));
22 |
23 | Dogs.Add(new Dog("Rex", Colors.Blue));
24 | Dogs.Add(new Dog("Daisy", Colors.Pink));
25 | Dogs.Add(new Dog("Snoopy", Colors.AliceBlue));
26 | }
27 |
28 | private void Any_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
29 | {
30 | if (e.NewItems != null)
31 | {
32 | foreach (BaseClass item in e.NewItems)
33 | {
34 | item.PropertyChanged += Item_PropertyChanged; ;
35 | }
36 | }
37 |
38 | if (e.OldItems != null)
39 | {
40 | foreach (BaseClass item in e.OldItems)
41 | {
42 | item.PropertyChanged -= Item_PropertyChanged;
43 | }
44 | }
45 |
46 | RaisePropertyChanged(nameof(GoingForAWalk));
47 | }
48 |
49 | private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
50 | {
51 | RaisePropertyChanged(nameof(GoingForAWalk));
52 | }
53 |
54 | public ObservableCollection Humen { get; } = new ObservableCollection();
55 |
56 | public ObservableCollection Dogs { get; } = new ObservableCollection();
57 |
58 | public IEnumerable GoingForAWalk
59 | {
60 | get
61 | {
62 | foreach (var human in Humen)
63 | {
64 | foreach (var dog in Dogs.Where(d => d.ColorOfLine == human.ColorOfLine))
65 | {
66 | yield return new Pair() { Dog = dog, Human = human };
67 | }
68 | }
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace ListViewDetailsExample
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/ExampleWithDetail.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Toolkit.Mvvm.ComponentModel;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace ListViewDetailsExample
7 | {
8 | public class ExampleWithDetail : ObservableObject
9 | {
10 | private string _Title;
11 | public string Title
12 | {
13 | get { return _Title; }
14 | set { SetProperty(ref _Title, value); }
15 | }
16 |
17 | private string _Detail;
18 | public string Detail
19 | {
20 | get { return _Detail; }
21 | set { SetProperty(ref _Detail, value); }
22 | }
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/ListViewDetailsExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | netcoreapp3.1
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace ListViewDetailsExample
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/ListViewDetailsExample/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Toolkit.Mvvm.ComponentModel;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.Text;
6 |
7 | namespace ListViewDetailsExample
8 | {
9 | public class ViewModel : ObservableObject
10 | {
11 | public ObservableCollection Examples { get; } = new ObservableCollection
12 | {
13 | new ExampleWithDetail() {Title ="Test 1" , Detail ="This is only visible if this ListViewItem is selected"},
14 | new ExampleWithDetail() {Title ="Test 2" , Detail ="This is also only visible if this ListViewItem is selected Like 'Test 1'"},
15 | new ExampleWithDetail() {Title ="Test 3" , Detail ="Another Test"},
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/Tims.Wpf.Examples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29920.165
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlinkingButton", "BlinkingButton\BlinkingButton.csproj", "{138A15F3-0664-466A-A5F5-F40831C7EE03}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntersectTwoLists", "IntersectTwoLists\IntersectTwoLists.csproj", "{65DD709B-8678-4164-A57A-B00297CE61A9}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HamburgerMenuCompositeExample", "HamburgerMenuCompositeExample\HamburgerMenuCompositeExample.csproj", "{372D68FA-D813-46CC-BAD2-CEA4068A7F10}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HamburgerMenuAutoPaneOpening", "HamburgerMenuAutoPaneOpening\HamburgerMenuAutoPaneOpening.csproj", "{D172DE9C-1464-473B-9F0A-B08815360084}"
13 | EndProject
14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataGridCellStyleExample", "DataGridCellStyleExample\DataGridCellStyleExample.csproj", "{8B330E02-6B61-43A2-A640-CC23E2088D2C}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DelayShowProgressExample", "DelayShowProgressExample\DelayShowProgressExample.csproj", "{9023B498-8AB2-426C-AA1F-007513FB9CC1}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilterDataGridExample", "FilterDataGridExample\FilterDataGridExample.csproj", "{190FB1F9-1DD7-4134-8D5C-2AECAFDB5491}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ListViewDetailsExample", "ListViewDetailsExample\ListViewDetailsExample.csproj", "{286B92EF-BCE7-4DC2-986C-D9D05F54FBE4}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testEmbed", "testEmbed\testEmbed.csproj", "{B6D53E7D-7944-45EF-908E-26B15D0B8065}"
23 | EndProject
24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComboBoxAndDataTableExample", "ComboBoxAndDataTableExample\ComboBoxAndDataTableExample.csproj", "{35346C24-15C8-418A-A04C-1B6B6AEB0051}"
25 | EndProject
26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomThemesExample", "CustomThemesExample\CustomThemesExample.csproj", "{9E08CE32-7BCA-49AC-BBFB-E78EB18F3BB4}"
27 | EndProject
28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowInDifferentThread", "WindowInDifferentThread\WindowInDifferentThread.csproj", "{B1ADADF5-6D15-430C-9DFB-3E669ADCCC34}"
29 | EndProject
30 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicDataExample", "DynamicDataExample\DynamicDataExample.csproj", "{28283D18-12FD-4B0B-9AC6-99E2FD0D24C0}"
31 | EndProject
32 | Global
33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
34 | Debug|Any CPU = Debug|Any CPU
35 | Release|Any CPU = Release|Any CPU
36 | EndGlobalSection
37 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
38 | {138A15F3-0664-466A-A5F5-F40831C7EE03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {138A15F3-0664-466A-A5F5-F40831C7EE03}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {138A15F3-0664-466A-A5F5-F40831C7EE03}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {138A15F3-0664-466A-A5F5-F40831C7EE03}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {65DD709B-8678-4164-A57A-B00297CE61A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {65DD709B-8678-4164-A57A-B00297CE61A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {65DD709B-8678-4164-A57A-B00297CE61A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {65DD709B-8678-4164-A57A-B00297CE61A9}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {372D68FA-D813-46CC-BAD2-CEA4068A7F10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {372D68FA-D813-46CC-BAD2-CEA4068A7F10}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {372D68FA-D813-46CC-BAD2-CEA4068A7F10}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {372D68FA-D813-46CC-BAD2-CEA4068A7F10}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {D172DE9C-1464-473B-9F0A-B08815360084}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {D172DE9C-1464-473B-9F0A-B08815360084}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {D172DE9C-1464-473B-9F0A-B08815360084}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {D172DE9C-1464-473B-9F0A-B08815360084}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {8B330E02-6B61-43A2-A640-CC23E2088D2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {8B330E02-6B61-43A2-A640-CC23E2088D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {8B330E02-6B61-43A2-A640-CC23E2088D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {8B330E02-6B61-43A2-A640-CC23E2088D2C}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {9023B498-8AB2-426C-AA1F-007513FB9CC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59 | {9023B498-8AB2-426C-AA1F-007513FB9CC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
60 | {9023B498-8AB2-426C-AA1F-007513FB9CC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {9023B498-8AB2-426C-AA1F-007513FB9CC1}.Release|Any CPU.Build.0 = Release|Any CPU
62 | {190FB1F9-1DD7-4134-8D5C-2AECAFDB5491}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63 | {190FB1F9-1DD7-4134-8D5C-2AECAFDB5491}.Debug|Any CPU.Build.0 = Debug|Any CPU
64 | {190FB1F9-1DD7-4134-8D5C-2AECAFDB5491}.Release|Any CPU.ActiveCfg = Release|Any CPU
65 | {190FB1F9-1DD7-4134-8D5C-2AECAFDB5491}.Release|Any CPU.Build.0 = Release|Any CPU
66 | {286B92EF-BCE7-4DC2-986C-D9D05F54FBE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67 | {286B92EF-BCE7-4DC2-986C-D9D05F54FBE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
68 | {286B92EF-BCE7-4DC2-986C-D9D05F54FBE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
69 | {286B92EF-BCE7-4DC2-986C-D9D05F54FBE4}.Release|Any CPU.Build.0 = Release|Any CPU
70 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Debug|Any CPU.Build.0 = Debug|Any CPU
72 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Release|Any CPU.ActiveCfg = Release|Any CPU
73 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Release|Any CPU.Build.0 = Release|Any CPU
74 | {35346C24-15C8-418A-A04C-1B6B6AEB0051}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75 | {35346C24-15C8-418A-A04C-1B6B6AEB0051}.Debug|Any CPU.Build.0 = Debug|Any CPU
76 | {35346C24-15C8-418A-A04C-1B6B6AEB0051}.Release|Any CPU.ActiveCfg = Release|Any CPU
77 | {35346C24-15C8-418A-A04C-1B6B6AEB0051}.Release|Any CPU.Build.0 = Release|Any CPU
78 | {9E08CE32-7BCA-49AC-BBFB-E78EB18F3BB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79 | {9E08CE32-7BCA-49AC-BBFB-E78EB18F3BB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
80 | {9E08CE32-7BCA-49AC-BBFB-E78EB18F3BB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
81 | {9E08CE32-7BCA-49AC-BBFB-E78EB18F3BB4}.Release|Any CPU.Build.0 = Release|Any CPU
82 | {B1ADADF5-6D15-430C-9DFB-3E669ADCCC34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83 | {B1ADADF5-6D15-430C-9DFB-3E669ADCCC34}.Debug|Any CPU.Build.0 = Debug|Any CPU
84 | {B1ADADF5-6D15-430C-9DFB-3E669ADCCC34}.Release|Any CPU.ActiveCfg = Release|Any CPU
85 | {B1ADADF5-6D15-430C-9DFB-3E669ADCCC34}.Release|Any CPU.Build.0 = Release|Any CPU
86 | {28283D18-12FD-4B0B-9AC6-99E2FD0D24C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87 | {28283D18-12FD-4B0B-9AC6-99E2FD0D24C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
88 | {28283D18-12FD-4B0B-9AC6-99E2FD0D24C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
89 | {28283D18-12FD-4B0B-9AC6-99E2FD0D24C0}.Release|Any CPU.Build.0 = Release|Any CPU
90 | EndGlobalSection
91 | GlobalSection(SolutionProperties) = preSolution
92 | HideSolutionNode = FALSE
93 | EndGlobalSection
94 | GlobalSection(ExtensibilityGlobals) = postSolution
95 | SolutionGuid = {D7BD19B9-B946-4301-BAF7-8BCBFDB7496A}
96 | EndGlobalSection
97 | EndGlobal
98 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace WindowInDifferentThread
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
11 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/ChildWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/ChildWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 | using System.Windows.Threading;
15 |
16 | namespace WindowInDifferentThread
17 | {
18 | ///
19 | /// Interaction logic for ChildWindow.xaml
20 | ///
21 | public partial class ChildWindow : Window
22 | {
23 | public SharedViewModel ViewModel { get; private set; }
24 |
25 | public ChildWindow()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 | private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
31 | {
32 | UpdateLocation();
33 | }
34 |
35 |
36 | public void SetViewModel(SharedViewModel sharedViewModel)
37 | {
38 | if (ViewModel is not null)
39 | {
40 | ViewModel.PropertyChanged -= ViewModel_PropertyChanged;
41 | }
42 |
43 | ViewModel = sharedViewModel;
44 | ViewModel.PropertyChanged += ViewModel_PropertyChanged;
45 |
46 | UpdateLocation();
47 | }
48 |
49 | private void UpdateLocation()
50 | {
51 | this.Dispatcher.InvokeAsync(() =>
52 | {
53 | var width = ViewModel.Width / 2;
54 | var height = ViewModel.Height / 2;
55 |
56 | this.Width = width;
57 | this.Height = height;
58 |
59 | var left = ViewModel.Left + ((ViewModel.Width - width) / 2);
60 | var top = ViewModel.Top + ((ViewModel.Height - height) / 2);
61 |
62 | this.Top = top;
63 | this.Left = left;
64 | }, DispatcherPriority.Send);
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace WindowInDifferentThread
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : Window
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 |
29 | private void Button_Click(object sender, RoutedEventArgs e)
30 | {
31 |
32 | var vm = this.DataContext as SharedViewModel;
33 |
34 | var thread = new Thread(() =>
35 | {
36 | var child = new ChildWindow();
37 | child.Show();
38 |
39 | child.Dispatcher.InvokeAsync(() => { child.SetViewModel(vm); });
40 |
41 | // shut donw the other thread when child is closed.
42 | child.Closed += (_, __) => child.Dispatcher.BeginInvokeShutdown(System.Windows.Threading.DispatcherPriority.Background);
43 |
44 | System.Windows.Threading.Dispatcher.Run();
45 | });
46 |
47 | thread.SetApartmentState(ApartmentState.STA);
48 | thread.IsBackground = true;
49 | thread.Start();
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/SharedViewModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Toolkit.Mvvm.ComponentModel;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace WindowInDifferentThread
9 | {
10 | public class SharedViewModel : ObservableObject
11 | {
12 |
13 | private double _Top;
14 | public double Top
15 | {
16 | get { return _Top; }
17 | set { SetProperty(ref _Top, value); }
18 | }
19 |
20 |
21 | private double _Left;
22 | public double Left
23 | {
24 | get { return _Left; }
25 | set { SetProperty(ref _Left, value); }
26 | }
27 |
28 |
29 | private double _Width = 600;
30 | public double Width
31 | {
32 | get { return _Width; }
33 | set { SetProperty(ref _Width, value); }
34 | }
35 |
36 |
37 | private double _Height = 450;
38 | public double Height
39 | {
40 | get { return _Height; }
41 | set { SetProperty(ref _Height, value); }
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/WindowInDifferentThread/WindowInDifferentThread.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net5.0-windows
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Configuration;
5 | using System.Data;
6 | using System.Diagnostics;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Reflection;
10 | using System.Threading.Tasks;
11 | using System.Windows;
12 |
13 | namespace testEmbed
14 | {
15 | ///
16 | /// Interaction logic for App.xaml
17 | ///
18 | public partial class App : Application
19 | {
20 | public App()
21 | {
22 | //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
23 |
24 |
25 | }
26 | private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
27 | {
28 | try
29 | {
30 | String resourceName = String.Empty;
31 | if (args.Name.Split(',')[0].EndsWith(".resources", StringComparison.InvariantCultureIgnoreCase))
32 | {
33 | resourceName = String.Format("testEmbed.Dependencies.{0}.dll", new AssemblyName(args.Name.Split(',')[0]).Name.Replace(".resources", ""));
34 | Debug.WriteLine(String.Format("Resource Loading(RESOURCE): {0}", new AssemblyName(args.Name.Split(',')[0]).Name.Replace(".resources", "")));
35 | }
36 | else
37 | {
38 | resourceName = String.Format("testEmbed.Dependencies.{0}.dll", new AssemblyName(args.Name.Split(',')[0]).Name);
39 | }
40 | Debug.WriteLine(String.Format("Resource Loading: {0}", resourceName));
41 | using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
42 | using (var outstream = new MemoryStream())
43 | {
44 | if (stream != null)
45 | {
46 | CopyTo(stream, outstream);
47 |
48 | return Assembly.Load(outstream.GetBuffer());
49 | }
50 | else
51 | {
52 | Debug.WriteLine(String.Format("Resource Failed: {0}" + Environment.NewLine + "{1}", resourceName, args.Name));
53 | return null;
54 | }
55 | }
56 | }
57 | catch (Exception ex)
58 | {
59 | Debug.WriteLine(ex.Message.ToString());
60 | return null;
61 | }
62 | }
63 | public static long CopyTo(Stream source, Stream destination)
64 | {
65 | byte[] buffer = new byte[2048];
66 | int bytesRead;
67 | long totalBytes = 0;
68 | while ((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0)
69 | {
70 | destination.Write(buffer, 0, bytesRead);
71 | totalBytes += bytesRead;
72 | }
73 | return totalBytes;
74 | }
75 |
76 | private void Application_Startup(object sender, StartupEventArgs e)
77 | {
78 |
79 | //// get the current app style (theme and accent) from the application
80 | //Tuple theme = ThemeManager.DetectAppStyle(Application.Current);
81 | //// now change app style to the custom accent and current theme
82 | //ThemeManager.ChangeAppStyle(Application.Current,
83 | // ThemeManager.GetAccent("Red"),
84 | // theme.Item1);
85 |
86 | MainWindow window = new MainWindow();
87 | window.Show();
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
13 |
14 |
15 |
16 |
17 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
18 |
19 |
20 |
21 |
22 | A list of unmanaged 32 bit assembly names to include, delimited with line breaks.
23 |
24 |
25 |
26 |
27 | A list of unmanaged 64 bit assembly names to include, delimited with line breaks.
28 |
29 |
30 |
31 |
32 | The order of preloaded assemblies, delimited with line breaks.
33 |
34 |
35 |
36 |
37 |
38 | This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.
39 |
40 |
41 |
42 |
43 | Controls if .pdbs for reference assemblies are also embedded.
44 |
45 |
46 |
47 |
48 | Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
49 |
50 |
51 |
52 |
53 | As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
54 |
55 |
56 |
57 |
58 | Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.
59 |
60 |
61 |
62 |
63 | Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.
64 |
65 |
66 |
67 |
68 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
69 |
70 |
71 |
72 |
73 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
74 |
75 |
76 |
77 |
78 | A list of unmanaged 32 bit assembly names to include, delimited with |.
79 |
80 |
81 |
82 |
83 | A list of unmanaged 64 bit assembly names to include, delimited with |.
84 |
85 |
86 |
87 |
88 | The order of preloaded assemblies, delimited with |.
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
97 |
98 |
99 |
100 |
101 | A comma-separated list of error codes that can be safely ignored in assembly verification.
102 |
103 |
104 |
105 |
106 | 'false' to turn off automatic generation of the XML Schema file.
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MahApps.Metro.Controls;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace testEmbed
18 | {
19 | ///
20 | /// Interaction logic for MainWindow.xaml
21 | ///
22 | public partial class MainWindow : MetroWindow
23 | {
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("testEmbed")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("testEmbed")]
15 | [assembly: AssemblyCopyright("Copyright © 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace testEmbed.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("testEmbed.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace testEmbed.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/testEmbed.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}
9 | WinExe
10 | testEmbed
11 | testEmbed
12 | v4.5.2
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 | true
18 |
19 |
20 |
21 |
22 | AnyCPU
23 | true
24 | full
25 | false
26 | bin\Debug\
27 | DEBUG;TRACE
28 | prompt
29 | 4
30 |
31 |
32 | AnyCPU
33 | pdbonly
34 | true
35 | bin\Release\
36 | TRACE
37 | prompt
38 | 4
39 |
40 |
41 | testEmbed.App
42 |
43 |
44 |
45 |
46 | ..\MahApps.Metro.Examples\packages\ControlzEx.4.2.2\lib\net45\ControlzEx.dll
47 |
48 |
49 | ..\MahApps.Metro.Examples\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll
50 |
51 |
52 | ..\MahApps.Metro.Examples\packages\MahApps.Metro.2.0.0-alpha0748\lib\net452\MahApps.Metro.dll
53 |
54 |
55 | ..\MahApps.Metro.Examples\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | 4.0
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | MSBuild:Compile
77 | Designer
78 |
79 |
80 | MSBuild:Compile
81 | Designer
82 |
83 |
84 | App.xaml
85 | Code
86 |
87 |
88 | MainWindow.xaml
89 | Code
90 |
91 |
92 |
93 |
94 | Code
95 |
96 |
97 | True
98 | True
99 | Resources.resx
100 |
101 |
102 | True
103 | Settings.settings
104 | True
105 |
106 |
107 | ResXFileCodeGenerator
108 | Resources.Designer.cs
109 |
110 |
111 |
112 | SettingsSingleFileGenerator
113 | Settings.Designer.cs
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/src/Tims.Wpf-Examples/testEmbed/testEmbed.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29926.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testEmbed", "testEmbed.csproj", "{B6D53E7D-7944-45EF-908E-26B15D0B8065}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B6D53E7D-7944-45EF-908E-26B15D0B8065}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {7FC530EA-2723-45CE-A808-7ECB45F2DDAD}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------