songdapeng
songdapeng
Explore posts from servers
CC#
Created by songdapeng on 6/9/2023 in #help
❔ WPF, deisgn to use ribbonmeun in every page and any page show in main frame
mainwindow.xaml
<Grid>
<!-- Ribbon -->
<local:MenuRibbonControl />

<!-- Main Content -->
<Frame x:Name="mainFrame" NavigationUIVisibility="Hidden"/>
</Grid>
<Grid>
<!-- Ribbon -->
<local:MenuRibbonControl />

<!-- Main Content -->
<Frame x:Name="mainFrame" NavigationUIVisibility="Hidden"/>
</Grid>
MenuribbonControl.xaml
<RibbonTab Header="Setting">
<RibbonGroup Header="Rooms Information">
<RibbonButton x:Name="RoomTypeButton" Label="ຂໍ້ມູນປະເພດຫ້ອງພັກ" Style="{StaticResource CustomRibbonButtonStyle}" Click="RoomTypeButton_Click">
<RibbonButton.LargeImageSource>
<BitmapImage UriSource="/icons/add_task.png" />
</RibbonButton.LargeImageSource>
</RibbonButton>
<RibbonTab Header="Setting">
<RibbonGroup Header="Rooms Information">
<RibbonButton x:Name="RoomTypeButton" Label="ຂໍ້ມູນປະເພດຫ້ອງພັກ" Style="{StaticResource CustomRibbonButtonStyle}" Click="RoomTypeButton_Click">
<RibbonButton.LargeImageSource>
<BitmapImage UriSource="/icons/add_task.png" />
</RibbonButton.LargeImageSource>
</RibbonButton>
MenuribbonControl.xaml.cs
public partial class MenuRibbonControl : UserControl
{
public MenuRibbonControl()
{
InitializeComponent();
}

private void RoomTypeButton_Click(object sender, RoutedEventArgs e)
{
if (Window.GetWindow(this) is MainWindow mainWindow)
{
mainWindow.mainFrame.Navigate(new RoomTypePage());
}
}
}
public partial class MenuRibbonControl : UserControl
{
public MenuRibbonControl()
{
InitializeComponent();
}

private void RoomTypeButton_Click(object sender, RoutedEventArgs e)
{
if (Window.GetWindow(this) is MainWindow mainWindow)
{
mainWindow.mainFrame.Navigate(new RoomTypePage());
}
}
}
roomtype.xaml
<Grid>
<TextBlock Text="Welcome to the Room Type Page!" FontSize="20" FontWeight="Bold" />
</Grid>
<Grid>
<TextBlock Text="Welcome to the Room Type Page!" FontSize="20" FontWeight="Bold" />
</Grid>
it can show correctly but the text "Welcome to the Room Type Page!" is not show in free space below ribbonmenu but show in higher ribbonmenu any one give me a suggestion the point to fix this?
5 replies