C
C#10mo ago
Prince J

For a XAML code, what code do you usually utilize to create a header to put your logo in?

Kinda a beginner however i'm a bit confused to how you can identify a header in your xaml where you can change it's color while also putting images of a logo in
18 Replies
Buddy
Buddy10mo ago
You mean Image?
Prince J
Prince JOP10mo ago
Yeah i'm trying to identify a header in my xaml so i can write a code where i can put a logo (an image) in Could be that i have the wrong thought process for this and just have to put a retangle and put an image up top of it
Buddy
Buddy10mo ago
Identify a header?
Prince J
Prince JOP10mo ago
Kinda like a html lol, like i said i could have the wrong thought process
Buddy
Buddy10mo ago
Just set the name of the control you want x:Name="foo" if WPF However I recommend learning MVVM (design pattern), it has a learning curve though
MODiX
MODiX10mo ago
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
leowest
leowest10mo ago
well it would be simple <image ...> but how u set it and how u write it depends on your layout and whether you're using code behind vc MVVM vs DataContext for example, some people like removing the default window border and creating their own with windowchrome, while some people just use the application icon to the window icon to their logo that would be different then setting a <image ..> control
leowest
leowest10mo ago
No description
Prince J
Prince JOP10mo ago
Yeah that's where i was trying to get at, just explained a bit vague
leowest
leowest10mo ago
like this one for example is an icon so to set that one u simple have to give your Window an attribute Icon="Icon1.ico" and have ico be a content in your application set to copy if newer, u can also have it as resource the way to add it there would be slightly different @Prince J is it that one that u want to change?
Prince J
Prince JOP10mo ago
Yes that's the one
leowest
leowest10mo ago
ah ok so yeah all you have to do is add Icon it can be a png, an ico etc
<Window x:Class="WpfApp1.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:WpfApp1.ViewModels"
xmlns:local="clr-namespace:WpfApp1.Views"
mc:Ignorable="d"
Title="{Binding Title}"
Height="450" Width="800" Icon="/Resources/Images/icon.png">
<Window x:Class="WpfApp1.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:WpfApp1.ViewModels"
xmlns:local="clr-namespace:WpfApp1.Views"
mc:Ignorable="d"
Title="{Binding Title}"
Height="450" Width="800" Icon="/Resources/Images/icon.png">
as an exemple, but if u want to change the executable icon then it would be a different location
Prince J
Prince JOP10mo ago
Thanks
leowest
leowest10mo ago
yw just for completeness the application icon i.e.: this
No description
leowest
leowest10mo ago
u would have to right click your project then go to properties then scroll all the way down to Package > General there u will see Icon
leowest
leowest10mo ago
No description
leowest
leowest10mo ago
this one is more strict and requires an actual ico file AFAIK $close
MODiX
MODiX10mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server