Fix position of Label - xaml

I have two buttons on either side of a Label.
If either of these Buttons get removed, I want the Label to stay centered in a fixed position.
Is there any way to lock the position of this Label?
<DockPanel LastChildFill="True">
<DockPanel DockPanel.Dock="Top" Margin="4,8,4,8" LastChildFill="True">
<Button Name="SearchBackButton" Style="{DynamicResourceInfoButtonStyle}" Content="{StaticResource SearchBackButton}"
VerticalAlignment="Center" HorizontalAlignment="Left" Margin="4,0,0,0" BorderBrush="Transparent" Background="Transparent" DockPanel.Dock="Left" Click="SearchBackButton_Click" />
<Label HorizontalAlignment="Center" FontFamily="HelveticaNeue" FontSize="14" FontStyle="Normal" FontWeight="SemiBold" Foreground="#273238" Name="SuggestedTemplatesText" Content="{x:Static res:UIStrings.SuggestedTemplates}"/>
<Button Name="info_icon" Style="{DynamicResource InfoButtonStyle}" Click="InfoButton_Click"
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,4,0" BorderBrush="Transparent" Background="Transparent" DockPanel.Dock="Right"/>
</DockPanel>
</DockPanel> <!-- Added by edit -->
This is the code for the Label and the two Buttons.

Related

WinUI3 ComboBox and Button have different size

we have a ComboBox and a Button next to eachother. They are in the same Grid.Rowin two different Grid.Columns.
However they both appeared to have a different size. Even by setting VerticalAlignment="Stretch" this did not change.
Last but not least I set an fixed height to both elements but they are still not the same size.
How dows that come and how can I change it?
Here is an image of the problem
This works on my sample app.
<Grid RowDefinitions="Auto,Auto">
<TextBlock Text="Test" Grid.Row="0" />
<Grid
Grid.Row="1"
ColumnDefinitions="Auto,Auto"
RowDefinitions="Auto,Auto">
<ComboBox
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Stretch"
CornerRadius="0"
SelectedIndex="0">
<TextBlock Text="Auswahlen" />
</ComboBox>
<Button
Grid.Row="1"
Grid.Column="1"
VerticalAlignment="Stretch"
CornerRadius="0">
<FontIcon
FontFamily="Segoe MDL2 Assets"
Glyph="" />
</Button>
</Grid>
</Grid>

WPF- Auto Resize the popup control

I am New WPF. I have PopupControl below is XAML for that:-
<Popup Name="PopupRemark" AllowsTransparency="True" Placement="Left" HorizontalOffset="45" VerticalOffset="-22"
PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ToggleButton}}"
IsOpen="{Binding IsChecked, ElementName=btnInfo}" StaysOpen="False" >
<Canvas Width="230" Height="200" Background="Transparent" >
<Path x:Name="Container" Canvas.Left="0" Canvas.Top="0" Fill="#f2f6f7" Stroke="#A9A9A9"
Data="M 230,40 L220,50 220,90 0,90 0,0 220,0 220,30 230,40">
<Path.Effect>
<DropShadowEffect BlurRadius="18" Color="Black" Opacity="0.4"/>
</Path.Effect>
</Path>
<Label Grid.Row="0" FontSize="13" FontWeight="Bold" FontFamily="Roboto" Content="Remark" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center"/>
<TextBlock Canvas.Left="5" Canvas.Top="25" Width="210" Text="{Binding Remark}" Foreground="#2c3e50" FontFamily="Roboto" FontSize="11" TextWrapping="Wrapwithoverflow" />
</Canvas>
</Popup>
Issue is, I want to set auto height & width for canvas or popup control so my popup will size as per content into it.I googled and knew that canvas should have fix height or width but is there any solution(Workaround) to make popup auto sizable.or how can add scroller into popup. It will be greatly appreciable
Thanks in advance

How to increase the size of the pivot arrows and make them fixed in UWP?

I have a pivot most used in the desktop and I want the arrows in the pivots to be fixed and not just to appear on hover and also to make the arrows larger(double) as they can be easily clicked.
I tried to find the parameter in the style component but unfortunately didn't have much luck there.
This is the default style for the Pivot element. https://msdn.microsoft.com/en-in/library/windows/apps/mt299144.aspx . Please update your required attribute to achieve the same. I updated height of the left and right navigation buttons(PreviousButton & NextButton) and thus it is reflecting in the UI
Here is the specific portion changes did in the default template:
<Button
x:Name="PreviousButton"
Grid.Column="1"
Template="{StaticResource PreviousTemplate}"
Width="20"
Height="72"
UseSystemFocusVisuals="False"
Margin="{ThemeResource PivotNavButtonMargin}"
IsTabStop="False"
IsEnabled="True"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Opacity="1"
Background="Transparent" />
<Button
x:Name="NextButton"
Grid.Column="1"
Template="{StaticResource NextTemplate}"
Width="20"
Height="72"
UseSystemFocusVisuals="False"
Margin="{ThemeResource PivotNavButtonMargin}"
IsTabStop="False"
IsEnabled="True"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Opacity="1"
Background="Transparent" />

ListView alignment issue in Windows 8

I have a strange issue, I tried every trick I knew to centre align the ListView placed inside a grid. No matter what, it looks like it is left aligned. The width and height of the ListView is data bound. (Width can take values 350 or 700 and height can take 100 or 200 depending on the Size settings. If size settings is compact it should be 350x100 and and if normal 700x200).
This is the xaml code
<Grid x:Name="GridPageLVPortrait" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Background="Beige" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,0,584.714,0" Width="781">
<ListView x:Name="PageLVPortrait" ItemsSource="{Binding}" CanReorderItems="True" AllowDrop="True" HorizontalAlignment="Center" SelectionMode="Single" IsSwipeEnabled="True" IsItemClickEnabled="True" SelectionChanged="PageLVPortraitSelectionChanged" ItemClick="PageLVPortraitItemClick" Height="{Binding TemplateHeight}" Width="{Binding TemplateWidth}" >
<ListView.ItemTemplate>
<DataTemplate>
<Canvas HorizontalAlignment="Center" Width="{Binding TemplateWidth}" Height="{Binding TemplateHeight}">
<Canvas.Background>
<ImageBrush ImageSource="{Binding PageBackground}"/>
</Canvas.Background>
<Image HorizontalAlignment="Center" Height="{Binding TemplateHeight}" Width="{Binding TemplateWidth}" Source="{Binding Page}" Stretch="None" Opacity="1" CacheMode="BitmapCache" />
<StackPanel x:Name="EditDeleteStackPanel" Width="{Binding TemplateWidth}" Height="{Binding TemplateHeight}" Opacity="0.95">
<Button x:Name="NoteDelete" HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="{x:Null}" Tapped="NoteDelete_Tapped" MinWidth="50" MinHeight="50" Margin="0,0,10,0" BorderBrush="{x:Null}" >
<Button.Background>
<ImageBrush ImageSource="{Binding Delete}"/>
</Button.Background>
</Button>
<Button x:Name="NoteEdit" HorizontalAlignment="Right" VerticalAlignment="Top" FontFamily="Segoe Script" FontSize="24" BorderBrush="{x:Null}" Tapped="NoteEdit_Tapped" Foreground="{x:Null}" MinWidth="50" MinHeight="50" Margin="0,0,10,0">
<Button.Background>
<ImageBrush ImageSource="{Binding Edit}"/>
</Button.Background>
</Button>
</StackPanel>
</Canvas>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
Could someone kindly help?
I've tried your code, in a whole page Grid with the normal dimension convention you provided (700x200). The listview does get center aligned if I ignore the grid's Margin="0,0,584.714,0". If you need the 584px in the right of the page, I'd say better put a grid's column there with that width.
I had found the issue. It is because the main grid is spit into 4 columns. And since this one uses columnspan, the alignment gets messed up.

TabItems with same size

I'm using tabitems for separating some information but as each one has different information, each one has a different size. I wonder how I could make both have the same size just changing the XAML file.
Basically, the code I did is:
<WrapPanel>
<DockPanel LastChildFill="False">
<TextBlock HorizontalAlignment="Left" DockPanel.Dock="Top" Text="Client Name" />
<TextBox MinWidth="100" HorizontalAlignment="Left" DockPanel.Dock="Top" Text="{Binding Path=ClientName, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True,NotifyOnValidationError=True}" MaxWidth="200" />
<TextBlock HorizontalAlignment="Left" DockPanel.Dock="Top" Text="Date" />
<TextBox MinWidth="100" HorizontalAlignment="Left" DockPanel.Dock="Top" Text="{Binding Path=ClientDate, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True,NotifyOnValidationError=True}" MaxWidth="200" />
<TabControl DockPanel.Dock="Top">
<TabItem ..>
</TabItem>
<TabItem ..>
</TabItem>
</TabControl>
<WrapPanel>
<Button ../>
<Button ../>
</WrapPanel>
</DockPanel>
</WrapPanel>
Regards
Claudio
Check
Let WPF Tabcontrol height assume height of largest item?
Comment here if it doesn't help