C
C#14mo ago
songdapeng

❔ 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?
3 Replies
HimmDawg
HimmDawg14mo ago
Can you show an image of what you exactly mean?
Shinyshark
Shinyshark14mo ago
I don't know how relevant it is, but if you've made a grid with two elements inside of it, you should also define how the rows / columns of the grid work. Otherwise they will both occupy the same row and column.
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.