C
C#7mo ago
Nadekai

I need to make this textbox not move

```c# <Window x:Class="Password_manager.MainWindow" 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:local="clr-namespace:Password_manager" mc:Ignorable="d" Title="MainWindow" Height="300" Width="400"> <Grid> <Label Margin="25">Select account</Label> <ComboBox Name="AccountBox" Width="140" Height="30" Margin="25,48,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"> </ComboBox> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock Height="40"> <Run Text="Password: "/> <Run Text="{Binding ElementName=AccountBox, Path=SelectedItem}"/> </TextBlock> <TextBlock x:Name="AccountPassword" Width="300" Height="40" FontSize="30"/> </StackPanel> </Grid> </Window>
No description
19 Replies
leowest
leowest7mo ago
because you're horizontally aligning it, so it will expand to both sides to keep it centered
Hlen_42
Hlen_427mo ago
taky řešíš závěrečku?:kekw: he knows
leowest
leowest7mo ago
Do you also deal with the final exam?
Hlen_42
Hlen_427mo ago
yep
leowest
leowest7mo ago
Keep it English This server is an English-first server. Keep voice and text channels in English to aid moderation and communication. Check ⁠how-to to create localised channels for translation purposes.
#info-and-rules
Buddy
Buddy7mo ago
Please do not use the designer $rulesofwpf
MODiX
MODiX7mo 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
Buddy
Buddy7mo ago
Margin is the spacing between elements, not absolute position
Nadekai
NadekaiOP7mo ago
Not using designer
leowest
leowest7mo ago
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
<Label Margin="25">Select account</Label>
<ComboBox Name="AccountBox" Width="140" Height="30">
<TextBlock Height="40">
<Run Text="Password: "/>
<Run Text="{Binding ElementName=AccountBox, Path=SelectedItem}"/>
</TextBlock>
<TextBlock x:Name="AccountPassword" Width="300" Height="40" FontSize="30"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
<Label Margin="25">Select account</Label>
<ComboBox Name="AccountBox" Width="140" Height="30">
<TextBlock Height="40">
<Run Text="Password: "/>
<Run Text="{Binding ElementName=AccountBox, Path=SelectedItem}"/>
</TextBlock>
<TextBlock x:Name="AccountPassword" Width="300" Height="40" FontSize="30"/>
</StackPanel>
https://wpf-tutorial.com/panels/grid/ https://wpf-tutorial.com/panels/stackpanel/
Nadekai
NadekaiOP7mo ago
Why is the button now displaying? <Window x:Class="Password_manager.MainWindow" 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:local="clr-namespace:Password_manager" mc:Ignorable="d" Title="MainWindow" Height="300" Width="400"> <Grid> <Label Margin="25">Select account</Label> <ComboBox Name="AccountBox" Width="140" Height="30" Margin="25,48,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"> </ComboBox> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock Height="40"> <Run Text="Password: "/> <Run Text="{Binding ElementName=AccountBox, Path=SelectedItem}"/> </TextBlock> <TextBlock x:Name="AccountPassword" Width="300" Height="40" FontSize="30"/> </StackPanel> <Button Width="120" Height="20" Margin="20,190,255,75" Click="Button_Click">Create New Account</Button>
</Grid> </Window> Also doesn't work
leowest
leowest7mo ago
works for me and I explained above why yours doesnt work
Nadekai
NadekaiOP7mo ago
No description
leowest
leowest7mo ago
ah yeah change orientation to vertical and remove the label margin if you want to space things around more, the use grids and look into the link I sent above about grids its explains how u can do it
leowest
leowest7mo ago
Nadekai
NadekaiOP7mo ago
No description
leowest
leowest7mo ago
<Grid>
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="Select account" />
<ComboBox Name="AccountBox" Width="140" Height="30" HorizontalAlignment="Left">
<ComboBoxItem>Something</ComboBoxItem>
</ComboBox>
<TextBlock Height="40">
<Run Text="Password: "/>
<Run Text="{Binding ElementName=AccountBox, Path=SelectedItem}"/>
</TextBlock>
<TextBlock x:Name="AccountPassword" Width="300" Height="40" FontSize="30"/>
</StackPanel>
</Grid>
<Grid>
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="Select account" />
<ComboBox Name="AccountBox" Width="140" Height="30" HorizontalAlignment="Left">
<ComboBoxItem>Something</ComboBoxItem>
</ComboBox>
<TextBlock Height="40">
<Run Text="Password: "/>
<Run Text="{Binding ElementName=AccountBox, Path=SelectedItem}"/>
</TextBlock>
<TextBlock x:Name="AccountPassword" Width="300" Height="40" FontSize="30"/>
</StackPanel>
</Grid>
Nadekai
NadekaiOP7mo ago
thankas
Want results from more Discord servers?
Add your server