-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathSearchPage.logic.cs
More file actions
46 lines (39 loc) · 1.4 KB
/
SearchPage.logic.cs
File metadata and controls
46 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
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
40
41
42
43
44
45
46
// IMPORTANT:
// In <page>.cs:
// Include CSharpMarkup namespace usings but no UI objectmodel usings.
// You *can* also use the UI objectmodel safely in <page>.cs; a good practice then is to
// define a "global using TypeName_UI = <UI objectmodel namespace>.TypeName" alias in GlobalUsings.cs
// In <page>.logic.cs:
// DO NOT include CSharpMarkup namespace usings and DO NOT use CSharpMarkup objects.
// Markup object instances are not safe to use outside of a markup expression (due to performance features).
// That is why Assign and Invoke pass the UI object to the logic, not the markup object.
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace WpfCsMarkupExamples;
internal sealed partial class SearchPage : BasePage, IBuild
{
static SearchViewModel.Tweet tweet = new();
readonly SearchViewModel vm;
StackPanel? header;
public SearchPage()
{
this.Initialized += OnInitialized;
DataContext = vm = App.Current!.SearchViewModel;
Build();
}
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
}
void OnInitialized(object? sender, EventArgs e)
{
}
static BitmapImage UriImage(string uri)
{
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(uri, UriKind.Absolute);
bitmap.EndInit();
return bitmap;
}
}