I made a flyout in C# with XAML now i want to change the background color of the space reserved for the title and back button. But that area is not defined in the flyout pages. Does anyone know how I can change the background color of the panel surrounding the title and backbutton?
<SettingsFlyout
x:Class="CatalogApp.FlyoutControl.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CatalogApp.FlyoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
IconSource="Assets/SmallLogo.png"
Title="Login"
d:DesignWidth="346">
<!-- This StackPanel acts as a root panel for vertical layout of the content sections -->
<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" RenderTransformOrigin="0.458,1.194" Width="250" >
<!-- The StackPanel(s) below define individual content sections -->
<!-- Content Section 1 Maring: left, up, down, right-->
<TextBlock x:Name="LBLuserName" TextWrapping="Wrap" Text="Username" FontSize="18" Margin="10,0,0,0"/>
<TextBox x:Name="TbUserName" TextWrapping="Wrap" Margin="10,0,0,0"/>
<TextBlock x:Name="LBLpassWord" TextWrapping="Wrap" FontSize="18" Text="Password" Margin="10,20,0,0"/>
<TextBox x:Name="TbPassWord" TextWrapping="Wrap" Margin="10,0,0,0" KeyDown="TbPassWord_KeyDown"/>
<TextBlock x:Name="TAWebService" TextWrapping="Wrap" Text="WebserviceURL (Inclusief HTTP://)" Margin=" 10,20,0,0" FontSize="15"/>
<TextBox x:Name="TBWebServiceURL" TextWrapping="Wrap" Margin="10,0,0,20" PlaceholderText=""/>
<Button x:Name="BTCheckConnection" Content="Check connectie" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,0,100,0" Click="BTCheckConnection_Click"/>
<TextBlock x:Name="TBConnection" TextWrapping="Wrap" Margin="10,20,0,0"/>
<Button x:Name="btTrue" Content="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="btTrue_Click"/>
<Button x:Name="btFalse" Content="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="btFalse_Click"/>
<!-- Content Section 1-->
<!-- Define more Content Sections below as necessary -->
</StackPanel>
You'll just add HeaderBackground like;
<SettingsFlyout
x:Class="CatalogApp.FlyoutControl.Login"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CatalogApp.FlyoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
IconSource="Assets/SmallLogo.png"
Title="Login"
d:DesignWidth="346"
HeaderBackground="Green">
Cheers
Related
Cant make button in WPF app with image and text on it. My code is like this:
<Window x:Class="WindowR.One"
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:WindowR"
mc:Ignorable="d"
Title="One" Height="300" Width="300">
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock Text="Click Here" />
<Image Source="D:\Skola\4. semester\TP\GIT folder\Visualko\Core\WindowR\Pictures\0.png" />
</StackPanel>
</Grid>
</Window>
But the text isnt above image..tried lots of tutorials from here..but none of them work properly
StackPanel arranges TextBlock next to Image. Try to use Grid
<Button Width="120" Height="50" >
<Grid>
<Image Source="D:\Skola\4. semester\TP\GIT folder\Visualko\Core\WindowR\Pictures\0.png" />
<TextBlock Text="Click Here"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
</Button>
I have a desktop application I am building in C# with XAML. I am having troube with the XAML side of things, and how its displayed on the preview compared to the actual program view.
I have tried putting the elements I am using into a grid, a stackPanel but it still has the same issue. Here is what the program should look like:
And how it actually appears in the program:
<Page x:Class="project.PayFees"
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:mosque"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="Pay Fees">
<Grid>
<Grid>
<Label Margin="67,90,641,328" Content="Amount Paid"/>
<Button Command="{Binding PayFees}" Content="Pay Fees" Margin="584,405,10,10"
RenderTransformOrigin="1.172,-3.328"/>
<Label Margin="67,62,691,360" Content="Date" RenderTransformOrigin="0.684,-0.03"/>
<TextBox x:Name="StudentID" Text="{Binding StudentID}" Width="130"
Margin="159,126,511,290" RenderTransformOrigin="-0.285,-6.056" />
<Label Content="Student ID" RenderTransformOrigin="3.77,3.251" Margin="67,126,663,292"/>
<TextBox x:Name="AmountPaid" Text="{Binding AmountPaid}" Width="130"
Margin="159,90,511,328" RenderTransformOrigin="0.039,0.004"/>
<TextBox Text="{Binding Date}" HorizontalAlignment="Left" Margin="159,52,0,0"
VerticalAlignment="Top" RenderTransformOrigin="2.704,6.1" Width="130" Height="32"/>
<Button Content="Load Student" HorizontalAlignment="Left" Margin="306,136,0,0"
VerticalAlignment="Top" Width="86" Height="22" Click="Button_Click"/>
<Label x:Name="studentName" Content="" HorizontalAlignment="Left" Margin="159,165,0,0"
VerticalAlignment="Top" Width="130"/>
</Grid>
</Grid>
This is my XAML code.
I can't figure out why this is happening - any advice is appreciated.
I'm fairly new to WPF and am working with some legacy code, not sure how to use the HeaderedContentControl Header. I'd like to put in a StackPanel and customize the look of a header, just not sure how to do that.
Could someone give me some guidance on what to do next?
I have this xaml and the HeaderTemplate is never used.
<UserControl x:Class="PEC.Admin.WindowsControls.Program.Views.ProgramProductEnrichmentColorsView"
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:commonControls="clr-namespace:ManagerConsole.Common.Controls;assembly=ManagerConsole.Common.Controls"
xmlns:program="clr-namespace:PEC.Admin.ViewModel.Program;assembly=PEC.Admin.ViewModel.Program"
mc:Ignorable="d"
d:DesignWidth="300"
d:DataContext="{d:DesignInstance program:ProgramProductEnrichmentColorsViewModel}">
<commonControls:ExpanderPanel IsExpanded="{Binding Path=IsExpanded,Mode=TwoWay}">
<HeaderedContentControl.HeaderTemplate> <!-- this never gets used... -->
<DataTemplate>
<StackPanel>
<Label Content="{Binding Path=Header}"></Label>
</StackPanel>
</DataTemplate>
</HeaderedContentControl.HeaderTemplate>
<StackPanel HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Width="Auto"
Margin="3"
Background="White">
<TextBlock Text="Source Type:"
Margin="0,5,0,0" />
<TextBox IsReadOnly="True"
IsTabStop="False"
Background="LightGray"
BorderThickness="0"
Text="{Binding Path=SourceTypeName, Mode=OneTime}" />
</StackPanel>
</commonControls:ExpanderPanel>
</UserControl>
HeaderTemplate is applied. To verify it - set a background to the Label in HeaderTemplate.
HeaderTemplate doesn't display anything though, because binding is incorrect. Template is applied to the data set in Header property, which currently has null value.
So change code as in the example below (I tried with Expander, hopefully it will work for custom commonControls:ExpanderPanel):
<Expander IsExpanded="{Binding Path=IsExpanded, Mode=TwoWay}"
Header="{Binding ComplexObject}">
<HeaderedContentControl.HeaderTemplate>
<DataTemplate>
<StackPanel>
<Label Background="Green" Content="{Binding PropertyOfTheObject}"/>
</StackPanel>
</DataTemplate>
</HeaderedContentControl.HeaderTemplate>
</Expander>
Header is a dependency property and can be set via Binding. Header becomes a source for bindings in a HeaderTemplate. Or it can be some constant (Header="Click to expand"), resource (Header="{StaticResource ExpandTitle}") or complex content, e.g.:
<Expander.Header>
<TextBlock Text="Click to expand"/>
</Expander.Header>
I want to make change main panel content when I choice action in menu button.
Like main content page, setting page, content page on Main panel (in code used grid x:Name="main_~~~)
It for use just can make 3 and control visibility??
or Can use include like xml at Android and change include target??
( ex > includelayout="#layout/app_bar_main")
Mainwindow.xaml
<Window x:Class="M_C.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:M_C"
mc:Ignorable="d"
Title="MainWindow"
Width="1024" Height="768"
WindowStyle="None"
WindowState="Maximized"
WindowStartupLocation="CenterScreen">
<Grid x:Name="wide_Out" Background="#000000">
<Viewbox Stretch="Uniform">
<Grid Width="1024" Height="768" VerticalAlignment="Top">
<DockPanel x:Name="L_black" HorizontalAlignment="Left"
Height="768" LastChildFill="False" VerticalAlignment="Top" Width="62"
Background="#FF242424">
<Button Margin="15,8,0,0" Height="40"
VerticalAlignment="Top" Width="30"/>
</DockPanel>
<DockPanel x:Name="T_blue" HorizontalAlignment="Left"
Height="84" LastChildFill="False" Margin="62,0,0,0" VerticalAlignment="Top"
Width="968" Background="#FF248BC7">
<TextBlock Margin="200,5,200,0" Height="70"
TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="554"/>
</DockPanel>
<DockPanel x:Name="L_blue" HorizontalAlignment="Left"
Height="685" LastChildFill="False" Margin="62,83,0,0"
VerticalAlignment="Top" Width="82" Background="#FF248BC7"/>
<DockPanel x:Name="R_blue" HorizontalAlignment="Left"
Height="685" LastChildFill="False" Margin="940,83,0,0"
Background="#FF248BC7" Width="84"/>
<DockPanel x:Name="B_blue" HorizontalAlignment="Left"
Height="90" LastChildFill="False" Margin="143,678,0,0"
VerticalAlignment="Top" Width="799" Background="#FF248BC7">
<Image Margin="250,15,250,15" Height="70"
VerticalAlignment="Top" Width="290" />
</DockPanel>
<!--<DockPanel x:Name="main_content_panel"
HorizontalAlignment="Left" Height="594" LastChildFill="False"
Margin="144,84,0,0" VerticalAlignment="Top" Width="790">-->
<Grid x:Name="main_con_body" Margin="143,82,84,88"
Width="798" Height="594" Background="#ffffff">
</Grid>
<!--</DockPanel>-->
</Grid>
</Viewbox>
</Grid>
</Window>
You can Define Frame inside Your Window and navigate between as many page you want:
<Frame Name="FrameWithinGrid" >
</Frame>
and on button Click you can simply navigate:
private void button1_Click(object sender, RoutedEventArgs e)
{
FrameWithinGrid.Navigate(new System.Uri("Page1.xaml",
UriKind.RelativeOrAbsolute));
}
to know more See here
MVVM Approach
Make main_con_body be a ContentControl
Make Window's DataContext a viewmodel
Bind main_con_body's Content property to a viewmodel property of the data context
Define different DataTemplates for the various types of viewmodels that might be present
Hi i have a wpf user control and wpf textbox control in a page, when i pressed on Tab in keyboard it's not going to next control which is a normal textbox. i had set the property Tabstop to true but nothing worked...
I have not created any special property for tab index in user control.
<StackPanel Orientation="Vertical">
//(User Control)
<controls:UserControl x:Name="txt_Name" Header="Name"/>
(Normal TextBox Control)
<StackPanel Orientation="Vertical" Margin="10">
<Label Content="Size" VerticalAlignment="Top" />
//(Normal TextBox Control)
<TextBox Name="txt_sizeofFacility"/>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="10">
<Label Content="Age" VerticalAlignment="Top" />
//(Normal TextBox Control)
<TextBox Name="txt_ageofFacility"/>
</StackPanel>
//(User Control)
<controls:UserControl x:Name="txt_primaryActivity" Header="Primary Activity"/>
</StackPanel>
This is my code:
<StackPanel Orientation="Vertical">
<!--//(User Control)-->
<controls:UserControl1 x:Name="txt_Name" />
<!--(Normal TextBox Control)-->
<StackPanel Orientation="Vertical" Margin="10">
<Label Content="Size" VerticalAlignment="Top" />
<!--//(Normal TextBox Control)-->
<TextBox Name="txt_sizeofFacility"/>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="10">
<Label Content="Age" VerticalAlignment="Top" />
<!--//(Normal TextBox Control)-->
<TextBox Name="txt_ageofFacility"/>
</StackPanel>
<!--//(User Control)-->
<controls:UserControl1 x:Name="txt_primaryActivity" />
</StackPanel>
And this is the UserControl:
<UserControl x:Class="TabIndex.UserControl1"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBox x:Name="test"></TextBox>
</Grid>
I can reproduce. Tab works even after setting focuse manually in each textbox
I had the same problem and found out that you can set the property below on the user control and that worked for me.
KeyboardNavigation.TabNavigation="Local"