I'm developing an app, using .NET Core 3.1. adding reference to Fluent Ribbon but when I write some XAML nothing shows.
<Window x:Class="WpfApp2.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:WpfApp2"
xmlns:fluent="urn:fluent-ribbon"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<fluent:Ribbon>
<fluent:Ribbon.Menu>
<fluent:Backstage>
<fluent:BackstageTabControl>
<fluent:BackstageTabItem Header="Database">
<WrapPanel Orientation="Horizontal">
<WrapPanel Orientation="Vertical">
<fluent:Button Header="Open Database" Foreground="Black" />
<fluent:Button Header="Save Database" Foreground="Black" />
<fluent:Button Header="Do something" Foreground="Black" />
</WrapPanel>
<fluent:TextBox Header="Database Name" Text="Your Database" Foreground="Black"/>
</WrapPanel>
</fluent:BackstageTabItem>
<fluent:Button x:Name="ExitButton" Header="Exit" />
</fluent:BackstageTabControl>
</fluent:Backstage>
</fluent:Ribbon.Menu>
</fluent:Ribbon>
</Grid>
</Window>
Any idea what I'm doing wrong?
You don't seem to have added any items to the Ribbon. You have only set the Menu property.
Try to add a RibbonTabItem to the Ribbon as they do in this basic setup:
<Fluent:RibbonWindow x:Class="MyFirstRibbonProject.MyFirstWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Fluent="urn:fluent-ribbon"
Title="My first RibbonWindow"
Width="800"
Height="600">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Fluent:Ribbon Grid.Row="0">
<!--Backstage-->
<Fluent:Ribbon.Menu>
<Fluent:Backstage>
</Fluent:Backstage>
</Fluent:Ribbon.Menu>
<!--Tabs-->
<Fluent:RibbonTabItem Header="Home">
<Fluent:RibbonGroupBox Header="Group">
<Fluent:Button Header="Green"
Icon="Resource-Path to your small icon for this button"
LargeIcon="Resource-Path to your large icon for this button" />
<Fluent:Button Header="Grey"
Icon="Resource-Path to your small icon for this button"
LargeIcon="Resource-Path to your large icon for this button" />
</Fluent:RibbonGroupBox>
</Fluent:RibbonTabItem>
</Fluent:Ribbon>
<Grid Grid.Row="1">
<TextBlock>My first window containing a Ribbon and something else.</TextBlock>
</Grid>
</Grid>
</Fluent:RibbonWindow>
I try to control my tab navigation. I made a little program to test it but i don't get what i want.
I want to tab in a certain order. And one of the tab focus on a user controle. Once i'm in a user controle i want to tab in another order. And then when all userControl Tab are done go back to my main control.
Because my code is really short i will paste it all.
First my mainWindow.
<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="450" Width="800">
<StackPanel KeyboardNavigation.TabNavigation="Local">
<TextBox Text="0" KeyboardNavigation.TabIndex="0" />
<TextBox Text="5" KeyboardNavigation.TabIndex="5" />
<local:Page1 KeyboardNavigation.TabIndex="3"/>
<TextBox Text="4" KeyboardNavigation.TabIndex="4" />
<TextBox Text="1" KeyboardNavigation.TabIndex="1" />
<TextBox Text="2" KeyboardNavigation.TabIndex="1" />
</StackPanel>
</Window>
Then the Page1 who are the userControl you see with TabIndex="3"
<UserControl x:Class="WpfApp1.Page1"
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:WpfApp1"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel KeyboardNavigation.TabNavigation="Contained">
<TextBox Text="Child 0" KeyboardNavigation.TabIndex="0" />
<TextBox Text="Child 1" KeyboardNavigation.TabIndex="1" />
<TextBox Text="Child 3" KeyboardNavigation.TabIndex="3" />
<TextBox Text="Child 2" KeyboardNavigation.TabIndex="2" />
</StackPanel>
</UserControl>
What i Get as Order when i Tab is
0 1 2 4 5 Child0 Child1 Child2 Child3
What i want is.
0 1 2 Child0 Child1 Child2 Child3 4 5
AnyWay to achieve this? I try to change TabNavigation to Local Container ect... And didn't find a way to make it work.
Remove KeyboardNavigation.TabNavigation="Contained" from the UserControl and try this:
<StackPanel>
<TextBox Text="0" KeyboardNavigation.TabIndex="0" />
<TextBox Text="5" KeyboardNavigation.TabIndex="5" />
<local:Page1 KeyboardNavigation.TabIndex="3" KeyboardNavigation.TabNavigation="Local"/>
<TextBox Text="4" KeyboardNavigation.TabIndex="4" />
<TextBox Text="1" KeyboardNavigation.TabIndex="1" />
<TextBox Text="2" KeyboardNavigation.TabIndex="2" />
</StackPanel>
I have been using MahApp.Metro for a few project now, and WinForms charts too, and also combined them.
So nothing new on that front in this project, except :
The placement of the chart.
And this is causing an issue where the Mahapps.Metro Flyout menu i have opens BEHIND the chart. See Screenshot.
Is there any way to solve this? i have searched a bit and found nothing. In CSS it would be a simple z-index setting... but in C# i have no idea.
Any help appreciated.
XAML as requested :
<Controls:MetroWindow x:Name="wdw_MainWindow" x:Class="AdminProgram.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:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:winformchart="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
xmlns:local="clr-namespace:AdminProgram"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="1024" GlowBrush="{DynamicResource AccentColorBrush}" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" BorderThickness="2,2,0,2" ShowMinButton="False" ShowMaxRestoreButton="False" IsMinButtonEnabled="False" IsMaxRestoreButtonEnabled="False" BorderBrush="#FF7C7C7C" TitleForeground="White">
<Controls:MetroWindow.Flyouts>
<Controls:FlyoutsControl>
<Controls:Flyout x:Name="fyo_Menu" Header="Menu" Width="200" Theme="Accent">
<Grid>
<Controls:Tile x:Name="btn_AddNew" Title="Add New"
Width="150" Height="150" TitleFontSize="20" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0" Click="btn_AddNew_Click" KeepDragging="False" MouseEnter="Tile_MouseEnter" MouseLeave="Tile_MouseLeave" BorderBrush="#FFC89632">
</Controls:Tile>
<Controls:Tile x:Name="btn_ViewAll" Title="View All"
Width="150" Height="150" TitleFontSize="20" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,160,0,0" Padding="0" Click="btn_ViewAll_Click" MouseEnter="Tile_MouseEnter" MouseLeave="Tile_MouseLeave" BorderBrush="#FFC89632" >
</Controls:Tile>
</Grid>
</Controls:Flyout>
</Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>
<GroupBox x:Name="gpb_Home_Stats" Header="Latest information and statistics" Margin="0,50,0,0">
<Grid>
<!--- Winforms Integrated charting -->
<!--Strength bars -->
<WindowsFormsHost x:Name="wfh_Statistics_Strengthometer" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0" Width="950" Height="425">
<winformchart:Chart x:Name="chart_Strengthometer" Dock="None">
<winformchart:Chart.Legends>
<winformchart:Legend Docking="Left" TitleSeparator="Line" Title="Coffee count by strength"/>
</winformchart:Chart.Legends>
<winformchart:Chart.Series>
<winformchart:Series Name="Strength" ChartType="Column"/>
</winformchart:Chart.Series>
<winformchart:Chart.ChartAreas>
<winformchart:ChartArea/>
</winformchart:Chart.ChartAreas>
</winformchart:Chart>
</WindowsFormsHost>
</Grid>
</GroupBox>
That's a known issue when mixing WinForms and WPF and is not related to MahApps.Metro. Just search for Airspace here at StackOverflow.
I have a project consisting of two pages. One page is having th XAML of a User control developed by me.
The another page has the logic of cropping the image that is present in the image box on that page. I want to use my control on that page and assign the border background of the user control to the image cropped .
The following code is of my UserControl XAML ! The cs file for this page has no code implementation
<UserControl
x:Class="controlMagnifier.MagnifierUsercontrol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:controlMagnifier"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Canvas x:Name="controlCanvas" x:FieldModifier="public" Margin="112,0,108,0">
<Canvas.RenderTransform>
<RotateTransform>
</RotateTransform>
</Canvas.RenderTransform>
<Grid Height="250" Width="176" Canvas.Left="41" Canvas.Top="40" Margin="-40,0,0,0">
<Border x:FieldModifier="public" x:Name="imgBorder" Width="150" CornerRadius="50,50,50,50" Margin="13,25,13,97">
<Border.Background>
<ImageBrush x:Name="image1" ImageSource="/Assets/images.jpg" />
</Border.Background>
</Border>
<TextBlock x:Name="txtreading" Height="30" Width="80" Margin="0,-145,0,0" FontWeight="Bold" Foreground="Red" FontSize="20" Text="ABC" TextAlignment="Center" />
<!--<Image Height="120" Width="150" Margin="0,-50,0,0" Source="Assets/SmallLogo.scale-100.png" ></Image>-->
<Path x:Name="MagnifyTip" Data="M25.533,0C15.457,0,7.262,8.199,7.262,18.271c0,9.461,13.676,19.698,17.63,32.338 c0.085,0.273,0.34,0.459,0.626,0.457c0.287-0.004,0.538-0.192,0.619-0.467c3.836-12.951,17.666-22.856,17.667-32.33 C43.803,8.199,35.607,0,25.533,0z M25.533,32.131c-7.9,0-14.328-6.429-14.328-14.328c0-7.9,6.428-14.328,14.328-14.328 c7.898,0,14.327,6.428,14.327,14.328C39.86,25.702,33.431,32.131,25.533,32.131z" Fill="#FFF4F4F5" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" Height="227" Width="171" />
</Grid>
</Canvas>
</UserControl>
In the user control XAML , we can see that I have set the
to a static image. I want to access this user control to another page and want to assign the element to the cropped image output on the other page. The other page MainPage.Xaml has the code for image cropping.
Any help would be appreciated
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"