So, when I create a new scrollbar the tab gets it. But when I scroll, it gets over the application menu too. I can't seem to find the solution and I tried everything.
My guess is that it's inside the dockpanel as well, but I don't know how to set it since if I added a new dockpanel it will say that "The property Content is set more than once."
Below you can see the code:
<Window
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
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:ContabilitateMainWPF.Forms.Main"
xmlns:WPF="clr-namespace:ContabilitateMain.Controls.WPF" x:Class="ContabilitateMainWPF.Forms.Main.FrmMainRibbon"
mc:Ignorable="d"
Title="Main" Closing="Window_Closing" Loaded="Window_Loaded" WindowState="Maximized" Icon="/ContabilitateMain;component/Imagini/new_window-512.png" WindowStyle="ToolWindow">
<DockPanel LastChildFill="True">
<ribbon:Ribbon DockPanel.Dock="Top " Margin="0,-22,0,0">
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\menu.png">
<ribbon:RibbonApplicationMenu.AuxiliaryPaneContent >
<StackPanel Orientation="Vertical" >
<GroupBox>
<Label Content="Ceva in group box" />
</GroupBox>
<StackPanel Orientation="Horizontal"/>
</StackPanel>
</ribbon:RibbonApplicationMenu.AuxiliaryPaneContent>
<ribbon:RibbonApplicationMenuItem x:Name="Salveaza" Header="Salveaza" />
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonTab x:Name="OptiuneaA" Header="Coloana A" MouseUp="OptiuneaA_MouseUp">
<ribbon:RibbonGroup x:Name="T1" Header="Optiunea 1">
<ribbon:RibbonButton x:Name="NouTab" Label="Tab PNG" LargeImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\new_window-512.png" Click="NouTab_Click"/>
<ribbon:RibbonButton x:Name="AltNouTab" Label="Tab JPG" LargeImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\new.jpg" Click="AltNouTab_Click"/>
</ribbon:RibbonGroup>
<ribbon:RibbonGroup x:Name="T2" Header="Optiunea 2">
<ribbon:RibbonButton x:Name="NouTab2" Label="Tab Nou" LargeImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\new_window-512.png"/>
<ribbon:RibbonButton x:Name="AltNouTab2" Label="Tab Secund" LargeImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\new.jpg"/>
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
<ribbon:RibbonTab x:Name="NouTab1" Header="Coloana B">
<ribbon:RibbonGroup x:Name="T3" Header="Optiunea 1">
<ribbon:RibbonButton x:Name="NouTab3" Label="Tab Nou" LargeImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\new_window-512.png"/>
<ribbon:RibbonButton x:Name="AltNouTab3" Label="Tab Secund" LargeImageSource="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\new.jpg"/>
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
<TabControl x:Name="actionTabs" DockPanel.Dock="Right" Background="White" SelectionChanged="actionTabs_SelectionChanged" >
<TabControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="15" Width="100">
<TextBlock Width="80" Text="{Binding Header}"/>
<Image Source="D:\PlasticWork\ContabilitateNou\ContabilitateMainWPF\Imagini\close.png" Width="20" Height="20" MouseUp="Image_MouseUp"/>
</StackPanel>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate x:Name="TabItem1">
<ScrollViewer>
<UserControl Content="{Binding Content}" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</ScrollViewer>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</DockPanel>
I expected to show to scroll only the tab, but it scrolls all the screen.
So apparently, the bug was because I tried to add a scrollbar to a window form, which was called from <UserControl Content="{Binding Content}" which was inside the tabcontrol. For some reason they connected eachother. I fixed it by adding the Scrollviewer to the UserControl, which looked something like this:
`<UserControl x:Class="ContabilitateMainWPF.Controls.TestUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ContabilitateMainWPF.Controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" SizeChanged="UserControl_SizeChanged">
<ScrollViewer>
<Grid x:Name="Grid">
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="199,0,0,0"/>
<Button x:Name="button_Copy" Content="Button" HorizontalAlignment="Left" Margin="141,91,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:Name="button_Copy1" Content="Button" HorizontalAlignment="Left" Margin="30,195,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:Name="button_Copy2" Content="Button" HorizontalAlignment="Left" Margin="199,261,0,0" VerticalAlignment="Top" Width="75"/>
<Label x:Name="label1" Content="LabelTest" HorizontalAlignment="Left" Margin="62,127,0,0" VerticalAlignment="Top"/>
</Grid>
</ScrollViewer>
</UserControl>`
Hope this helps someone one day.
Related
I have started learning wpf. I am trying to use line element but whenever i try to run this code line is not visible at all. Same case with rectangle, I have used rectangle element as well but it is also not showing up. What is the problem? I don't understand. I am able to see that in designer view but not in the runtime.
<Window x:Class="Mi_Express.Product_Details"
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:Mi_Express"
mc:Ignorable="d"
Title="Product_Details" Height="1920" Width="1080" WindowState="Maximized" ResizeMode="NoResize" WindowStyle="None"
Foreground="White" FontSize="30" FontWeight="Bold" Topmost="True" Background="White">
<Grid>
<Line HorizontalAlignment="Stretch" X1="10" Y1="10" X2="870" Y2="10" Stroke="Black" StrokeThickness="4" Margin="120,180,79,1712"/>
<Label Content="Shopping Cart:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="157,125,0,0" FontSize="30" FontWeight="DemiBold"/>
<Rectangle HorizontalAlignment="center" Height="73" Stroke="Black" StrokeThickness="3" VerticalAlignment="Top" Width="1017" Margin="28,1663,35,0"
/>
<Image HorizontalAlignment="Left" Height="102" VerticalAlignment="Top" Width="139" Margin="157,270,0,0"/>
<Button Content="Go Back" ClickMode="Press" Background="#FFE87E04" BorderBrush="#e87e04" FontSize="18" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" Width="174" Margin="157,1786,0,0" Height="61"/>
<Button Content="Continue" ClickMode="Press" Background="#e87e04" BorderBrush="#e87e04" FontSize="18" Foreground="white" HorizontalAlignment="Right" VerticalAlignment="Top" Width="160" Margin="0,1786,159,0" Height="61"/>
</Grid>
</Window>
The problem here is with the structure of your grid ..Dont apply margin to any of the UI elements over here.. instead remove it and use grid.column to position your UI elements..I have modified your code a litte
<Window x:Class="WpfApp1.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:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Line Grid.Column="0" HorizontalAlignment="Stretch" X1="10" Y1="10" X2="870" Visibility="Visible" Y2="10" Stroke="Red" StrokeThickness="4" Margin="12,18,79,171"/>
<Label Grid.Column="1" Content="Shopping Cart:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="157,125,0,0" FontSize="30" FontWeight="DemiBold"/>
<Rectangle Grid.Column="2"
Visibility="Visible"
Fill="Blue"
HorizontalAlignment="center" Height="73" Stroke="Black" StrokeThickness="3" VerticalAlignment="Top" Width="1017" Margin="28,166,35,0"
/>
<Image HorizontalAlignment="Left" Height="102" VerticalAlignment="Top" Width="139" Margin="157,270,0,0"/>
<Button Content="Go Back" ClickMode="Press" Background="#FFE87E04" BorderBrush="#e87e04" FontSize="18" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" Width="174" Margin="157,1786,0,0" Height="61"/>
<Button Content="Continue" ClickMode="Press" Background="#e87e04" BorderBrush="#e87e04" FontSize="18" Foreground="white" HorizontalAlignment="Right" VerticalAlignment="Top" Width="160" Margin="0,1786,159,0" Height="61"/>
</Grid>
For more information on how to use grid in wpf .. please follow this links:
1) http://www.c-sharpcorner.com/UploadFile/1e050f/grid-layout-in-wpf/
2) http://www.wpf-tutorial.com/panels/grid-rows-and-columns/
3) https://wpftutorial.net/GridLayout.html
The problem is in the margin. Bottom margin is way too high and line goes out of the window
I guess you mistaken height with width and you ment Width="1920" Height="1080". Even so the actually height of the grid it would not be 1080, you can check it using this line
<Label Content="{Binding ElementName=grid,Path=ActualHeight}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="157,175,0,0" FontSize="30" FontWeight="DemiBold"/>
I am trying to implement splitview in my app.But when ii set IsPaneOpen = true;
My pivots are not moving to right of that split view pane.Insted SplitView Pane opens Over pivotItems.
Someone please help me to resolve this.
Thanks in advance.
My Main page:
<Page
x:Class="SplitView.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SplitView"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<RelativePanel x:Name="myrelativepanel">
<Pivot x:Name="mypivot" RelativePanel.AlignRightWith="spv">
<PivotItem x:Name="header1" Header="Header1">
<ListBox x:Name="listView"
HorizontalAlignment="Left"
Height="Auto"
VerticalAlignment="Top"
Width="172"
ItemsSource="{x:Bind itemsList}"
/>
</PivotItem>
<PivotItem x:Name="header2" Header="Header2">
<ListBox x:Name="listView1"
HorizontalAlignment="Left"
Height="Auto"
VerticalAlignment="Top"
Width="172"
ItemsSource="{x:Bind itemsList}"
/>
</PivotItem>
</Pivot>
<local:SplitViewPage x:Name="spv"></local:SplitViewPage>
</RelativePanel>
</Grid>
</Page>
My SplivView page:
<Page
x:Class="SplitView.SplitViewPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SplitView"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<SplitView x:Name="MySplitView" DisplayMode="CompactOverlay" IsPaneOpen="False"
CompactPaneLength="50" OpenPaneLength="150">
<SplitView.Pane>
<StackPanel Background="Gray">
<Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content=""
Width="50" Height="50" Background="Transparent" Click="HamburgerButton_Click"/>
<StackPanel Orientation="Horizontal">
<Button x:Name="MenuButton1" FontFamily="Segoe MDL2 Assets" Content=""
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Button 1" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button x:Name="MenuButton2" FontFamily="Segoe MDL2 Assets" Content=""
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Button 2" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button x:Name="MenuButton3" FontFamily="Segoe MDL2 Assets" Content=""
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Button 3" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
</StackPanel>
</SplitView.Pane>
<SplitView.Content>
<Grid>
<TextBlock Text="SplitView Basic" FontSize="54" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</SplitView.Content>
</SplitView>
</Page>
Use display mode CompactInline, instead of CompactOverlay on your splitview.
DisplayMode="CompactInline"
I have a problem with WPF... it's kinda odd.
I recently migrated to using MahApps.Metro for my window and when I'm on my Login Screen it flickers between cleartype and non-cleartype every few seconds
Here are my XAML files
MainWindow.xaml
<Controls:MetroWindow x:Class="LegendaryClient.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="LegendaryClient" Height="600" Width="1024" MinHeight="600" MinWidth="1024"
ShowIconOnTitleBar="True" SaveWindowPosition="True" Icon="Icon.ico" ResizeMode="CanResizeWithGrip" TitleCaps="False">
<Controls:MetroWindow.WindowCommands>
<Controls:WindowCommands>
<Button Content="settings" />
<Button x:Name="ThemeButton" Click="ThemeButton_Click" Content="theme"/>
</Controls:WindowCommands>
</Controls:MetroWindow.WindowCommands>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="Controls/Steel.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<ContentControl x:Name="Container" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</Grid>
</Controls:MetroWindow>
and
<Page x:Class="LegendaryClient.Windows.LoginPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
d:DesignHeight="672" d:DesignWidth="1024"
Title="LoginPage">
<Grid Background="Black" Margin="0">
<Image x:Name="LoginImage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="UniformToFill" Panel.ZIndex="-2" />
<Label x:Name="WelcomeLabel" Content="Login to League of Legends" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="24" FontWeight="Bold" Foreground="White" Margin="25,0,0,290">
<Label.Effect>
<DropShadowEffect ShadowDepth="3"/>
</Label.Effect>
</Label>
<Grid HorizontalAlignment="Left" Height="230" VerticalAlignment="Bottom" Width="350" Margin="20,0,0,50">
<Grid x:Name="LoginGrid" HorizontalAlignment="Left" Height="230" VerticalAlignment="Top" Width="350">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Username" VerticalAlignment="Top" Foreground="White" Margin="10,10,0,0" FontSize="18" FontWeight="Bold"/>
<TextBox x:Name="LoginUsernameBox" TextWrapping="NoWrap" VerticalAlignment="Top" Width="330" HorizontalAlignment="Left" Margin="10,40,0,0" FontSize="16"/>
<CheckBox x:Name="RememberUsernameCheckbox" Content="Remember Username" HorizontalAlignment="Right" Margin="0,80,10,0" VerticalAlignment="Top" Foreground="White" IsChecked="True"/>
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Password" VerticalAlignment="Top" Foreground="White" Margin="10,90,0,0" FontSize="18" FontWeight="Bold"/>
<PasswordBox x:Name="LoginPasswordBox" VerticalAlignment="Top" Width="330" HorizontalAlignment="Left" Margin="10,120,0,0" FontSize="16"/>
<CheckBox x:Name="RememberPasswordCheckbox" Content="Remember Password" HorizontalAlignment="Right" Margin="0,160,10,0" VerticalAlignment="Top" Foreground="White" />
<Button x:Name="LoginButton" Content="Login" HorizontalAlignment="Stretch" Margin="10,180,10,0" VerticalAlignment="Top" Height="41" Click="LoginButton_Click" IsDefault="True" />
<ComboBox x:Name="RegionComboBox" ItemsSource="{DynamicResource Regions}" HorizontalAlignment="Left" Margin="220,10,0,0" VerticalAlignment="Top" Width="120" SelectedIndex="5"/>
</Grid>
<Controls:ProgressRing x:Name="LoggingInProgressRing" IsActive="True" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,10,0,0" Visibility="Hidden"/>
<Label x:Name="LoggingInLabel" Content="Logging in..." HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="36" FontWeight="Bold" Foreground="White" Visibility="Hidden"/>
<Grid.Effect>
<DropShadowEffect/>
</Grid.Effect>
</Grid>
<TextBox x:Name="ErrorTextBox" Text="Error" HorizontalAlignment="Left" VerticalAlignment="Bottom" TextWrapping="NoWrap" IsReadOnly="True" Width="350" Height="20" FontSize="12" FontWeight="999" Foreground="#FFFF7373" Margin="25,0,0,15" Background="{x:Null}" Panel.ZIndex="-1" BorderBrush="{x:Null}" Visibility="Hidden">
<TextBox.Effect>
<DropShadowEffect ShadowDepth="3"/>
</TextBox.Effect>
</TextBox>
</Grid>
</Page>
Any help would be appreciated.
Thanks!
Turns out <Controls:ProgressRing x:Name="LoggingInProgressRing" IsActive="True" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,10,0,0" Visibility="Hidden"/> was causing my text to flicker for some reason... Putting it outside the grid stopped the blurring
I'm new in WPF and I'm trying to show an image in a WPF windows, and then show a button, and two links in a absulute coordinate. I have two problems:
The floating controls are moved from one computer to other
The image is blurred. I think that is being resized.
The form must be a fixed dialog, and the image size is 800x560.
Here is my code:
<Window
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" mc:Ignorable="d" x:Class="A.B.C.IntroGuideWindow"
Title="Intro guide" Icon="../Resources/app_icon.ico"
Background="{DynamicResource DialogBackgroundBrush}" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
WindowStyle="None"
Style="{DynamicResource WindowStyle}" SnapsToDevicePixels="True" TextOptions.TextFormattingMode="Display" Width="830" Height="660">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../ResourceDictionaries/Colors.xaml"/>
<ResourceDictionary Source="../ResourceDictionaries/BasicStyles/StandardWindowStyle.xaml"/>
<ResourceDictionary Source="../ResourceDictionaries/ButtonStyles/ActionFlatButtonStyle.xaml"/>
<ResourceDictionary Source="../ResourceDictionaries/ButtonStyles/CancelButtonStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid VerticalAlignment="Top">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="22"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Margin="10,10,10,10" FontFamily="Segoe UI" FontSize="21"
FontWeight="SemiBold" Foreground="{DynamicResource FontBrush}" Grid.Row="0">
<Run Text="Intro guide" />
</TextBlock>
<Button x:Name="closeButton" Style="{DynamicResource CloseChromeButtonStyle}"
Click="CancelButton_Click" Grid.Row="0"
Content="r" HorizontalAlignment="Right" Margin="0,6,6,0" FontFamily="Webdings" IsTabStop="False" />
<Image x:Name="CurrentImage" Grid.Row="1" Width="800" Height="560" Stretch="None" Source="Images/sm-eval-guide-09.png" SnapsToDevicePixels="True"/>
<Button x:Name="OpenSamplesButton" Content="Click here to open the samples directory" IsDefault="False"
Style="{DynamicResource ActionFlatButtonStyle}"
Margin="256,115,265,434" Width="301" Height="23" Click="OpenSamplesButton_Click" Grid.Row="1"/>
<TextBlock x:Name="DocumentationLink" Margin="2,221,-2,333" Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" FontWeight="Bold">
<Hyperlink Foreground="#00A586" NavigateUri="http://www.example.com/#documentation">http://www.example.com/#documentation</Hyperlink>
</TextBlock>
<TextBlock x:Name="TwitterLink" Margin="590,415,84,137" Grid.Row="1" VerticalAlignment="Center" FontFamily="Arial" FontSize="16" FontWeight="Bold">
<Hyperlink Foreground="#00A586" NavigateUri="https://twitter.com/xxx">#xxx</Hyperlink>
</TextBlock>
<Grid VerticalAlignment="Top" Grid.Row="2">
<Button x:Name="PreviousButton" Content="Previous" IsDefault="False"
Style="{DynamicResource ActionFlatButtonStyle}"
Margin="0,0,200,10" Width="90" HorizontalAlignment="Right" Click="PreviousButton_Click"/>
<Button x:Name="NextButton" Content="Next" IsDefault="True"
Style="{DynamicResource ActionFlatButtonStyle}"
Margin="0,0,105,10" Width="90" HorizontalAlignment="Right" Click="NextButton_Click"/>
<Button x:Name="CloseButton" Content="Close" IsDefault="False"
Style="{DynamicResource ActionFlatButtonStyle}"
Margin="0,0,10,10" Width="90"
VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="CloseButton_Click"/>
<CheckBox x:Name="DontShowAgainCheckbox" Content="Don't show this window again." HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Checked="DontShowAgainCheckbox_Checked"/>
</Grid>
</Grid>
</Window>
WPF adjusts for pixel density of the monitor it is running on. Consider using Grid Columns or other layout controls such as StackPanel instead of Margin offsets. For example, your buttons could use the following layout:
<StackPanel Orientation="Horizontal" Margin="10,0" HorizontalAlignment="Right">
<Button x:Name="PreviousButton" Content="Previous" IsDefault="False"
Style="{DynamicResource ActionFlatButtonStyle}" Margin="4,0"
Width="90" Click="PreviousButton_Click"/>
<Button x:Name="NextButton" Content="Next" IsDefault="True"
Style="{DynamicResource ActionFlatButtonStyle}" Margin="4,0"
Width="90" Click="NextButton_Click"/>
<Button x:Name="CloseButton" Content="Close" IsDefault="False"
Style="{DynamicResource ActionFlatButtonStyle}" Margin="4,0"
Width="90" Click="CloseButton_Click"/>
</StackPanel>
For the blurred image, try using UseLayoutRounding="False" in your Image definition.
I have the following XAML code for a stackpanel, which places an image to the left and a textblock in the right
<StackPanel Height="Auto" HorizontalAlignment="Stretch" Margin="12,0" Name="stackPanel1" VerticalAlignment="Top" Width="Auto" Grid.Row="1" Orientation="Horizontal" Background="White">
<Image Height="240" Name="image1" Stretch="Fill" Width="240" HorizontalAlignment="Left" />
<Grid Height="Auto" Name="grid1" Width="Auto">
<TextBlock Height="Auto" HorizontalAlignment="Left" Margin="6,6,0,0" Name="textBlock1" Text="CVC for strict action on tax evasions, black money" VerticalAlignment="Top" Width="Auto" Foreground="Black" FontSize="24" TextWrapping="Wrap" />
</Grid>
</StackPanel>
This produces an overflowing text in the textblock, that goes outside the boundaries. I want a stackpanel such that on changing the image size, the textblock resizes accordingly and the total stackpanel always remains stretched out.
EDITS:
The whole code of the entire xaml is:
<phone:PhoneApplicationPage
x:Class="PanelFullStretch30_9_19_02.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<controls:Pivot Title="MY APPLICATION" Background="Gainsboro" Foreground="Black">
<!--Pivot item one-->
<controls:PivotItem Header="first">
<ListBox x:Name="ExampleBox">
</ListBox>
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem Header="second">
<!--Triple line list no text wrapping-->
<ListBox x:Name="SecondListBox">
<!-- Pic on left stackpanel design-->
<StackPanel Height="Auto" HorizontalAlignment="Stretch" Margin="12,0" Name="stackPanel1" VerticalAlignment="Top" Width="Auto" Grid.Row="1" Orientation="Horizontal" Background="White">
<Image Height="240" Name="image1" Stretch="Fill" Width="240" HorizontalAlignment="Left" />
<Grid Height="Auto" Name="grid1" Width="Auto">
<TextBlock Height="Auto" HorizontalAlignment="Left" Margin="6,6,0,0" Name="textBlock1" Text="CVC for strict action on tax evasions, black money" VerticalAlignment="Top" Width="Auto" Foreground="Black" FontSize="24" TextWrapping="Wrap" />
</Grid>
</StackPanel>
</ListBox>
</controls:PivotItem>
</controls:Pivot>
</Grid>
<!--Sample code showing usage of ApplicationBar-->
<!--<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>-->
</phone:PhoneApplicationPage>
Whenever you want an adaptive layout, use Grid. For example, the following XAML will generate a Grid with two columns: the left is being automatically resized while the second one fills the remaining space:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
Put your image in the first column and the text in the second column. This will ensure your desired layout.