mui icon indicating copy to clipboard operation
mui copied to clipboard

Remove back button

Open as510 opened this issue 8 years ago • 8 comments

Hi,

I am very new to .net programming. Could you please tell me how to get rid of the back button that is shown by default in all themes?

as510 avatar Aug 19 '15 20:08 as510

http://www.c-sharpcorner.com/UploadFile/3789b7/modern-ui-for-wpf-application-by-example-default-window-wit/

nunnally avatar Aug 20 '15 01:08 nunnally

Are you sure that this is still working? I am trying this and I am getting a lot of errors. Maybe it is because I am failing at the first step (new to it, too). In visual studio I create a folder "Themes" in the root of my project. After this I am filling it with all the xaml files I downloaded from the Codeplex project.

At least, I am trying to create a Theme without the navigation but with the TitleLinks

ghost avatar Aug 20 '15 19:08 ghost

I've been working on the same thing, but am eliminating the menu link group as well. I'm down to one error in the TitleLinks section Command="navigation:LinkCommands.NavigateLink" says NavigateLink is not in the namespace. I can't get to it in code either. I had to change the style for the systemclosebutton and add the navigation namespace. Below is my current xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mui="http://firstfloorsoftware.com/ModernUI" xmlns:controls="clr-namespace:FirstFloor.ModernUI.Windows.Controls" xmlns:modernUi="clr-namespace:FirstFloor.ModernUI;assembly=FirstFloor.ModernUI" xmlns:navigation="clr-namespace:FirstFloor.ModernUI.Windows.Navigation">

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Button.xaml" />
    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Converters.xaml" />
    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/TextBlock.xaml" />
</ResourceDictionary.MergedDictionaries>

<Style TargetType="mui:ModernWindow" x:Key="MyModernWindow">
    <Setter Property="BackgroundContent" Value="{DynamicResource WindowBackgroundContent}" />
    <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
    <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
    <Setter Property="Foreground" Value="{DynamicResource WindowText}" />
    <Setter Property="BorderBrush" Value="{DynamicResource WindowBorder}" />
    <Setter Property="Width" Value="800" />
    <Setter Property="Height" Value="640" />
    <Setter Property="MinWidth" Value="320" />
    <Setter Property="MinHeight" Value="320" />
    <Setter Property="ResizeMode" Value="CanResizeWithGrip" />
    <Setter Property="UseLayoutRounding" Value="True" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />

    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="mui:ModernWindow">
                <Border x:Name="WindowBorder" Margin="{Binding Source={x:Static SystemParameters.WindowNonClientFrameThickness}}">
                    <Border.Background>
                        <SolidColorBrush x:Name="WindowBorderBackground" Color="{DynamicResource WindowBackgroundColor}" />
                    </Border.Background>
                    <Border.Resources>
                        <Storyboard x:Key="BackgroundAnimation">
                            <ColorAnimation Storyboard.TargetName="WindowBorderBackground" Storyboard.TargetProperty="Color" To="{DynamicResource WindowBackgroundColor}" Duration="0:0:.6" />
                        </Storyboard>
                    </Border.Resources>

                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1">
                        <AdornerDecorator>
                            <Grid x:Name="LayoutRoot">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="36" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>

                                <!-- window background content -->
                                <ContentControl Grid.RowSpan="5" Content="{TemplateBinding BackgroundContent}" />

                                <!-- title bar -->
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="96" />
                                    </Grid.ColumnDefinitions>

                                    <!-- title -->
                                    <TextBlock Text="{TemplateBinding Title}" Margin="8,0" VerticalAlignment="Center" Style="{StaticResource ModernWindowTitle}"
                                               DataContext="{TemplateBinding IsTitleVisible}"
                                               Visibility="{Binding Converter={StaticResource BooleanToVisibilityConverter}}"/>

                                    <!-- title links -->
                                    <ItemsControl Grid.Column="1" ItemsSource="{TemplateBinding TitleLinks}" Margin="0,0,24,0" WindowChrome.IsHitTestVisibleInChrome="True">
                                        <ItemsControl.ItemsPanel>
                                            <ItemsPanelTemplate>
                                                <StackPanel Orientation="Horizontal" />
                                            </ItemsPanelTemplate>
                                        </ItemsControl.ItemsPanel>
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Line x:Name="Separator" X1=".5" Y1="3" X2=".5" Y2="12" Margin="5,0" VerticalAlignment="Center" Stroke="{DynamicResource SeparatorBackground}" />

                                                    <Button Content="{Binding DisplayName}"
                                                            Command="navigation:LinkCommands.NavigateLink"
                                                            CommandParameter="{Binding Source}"
                                                            CommandTarget="{Binding ElementName=ContentFrame}"
                                                            Style="{StaticResource SystemButtonLink}" />
                                                </StackPanel>
                                                <DataTemplate.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}" Value="{x:Null}">
                                                        <Setter Property="Visibility" TargetName="Separator" Value="Collapsed"/>
                                                    </DataTrigger>
                                                </DataTemplate.Triggers>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>

                                    <!-- logo (visible only when LogoData is not null) -->
                                    <Border Grid.Column="2" Background="{DynamicResource Accent}" Width="36" Height="36" Margin="8,0"
                                            DataContext="{TemplateBinding LogoData}"
                                            Visibility="{Binding Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=inverse}">
                                        <Path Data="{Binding}" Stretch="Fill" Fill="White" Width="24" Height="24" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                    </Border>

                                    <!-- window system buttons-->
                                    <StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Top" WindowChrome.IsHitTestVisibleInChrome="True" HorizontalAlignment="Right">
                                        <Button Command="{Binding Source={x:Static SystemCommands.MinimizeWindowCommand}}" ToolTip="{x:Static modernUi:Resources.Minimize}" Style="{StaticResource SystemButton}">
                                            <Button.Content>
                                                <Grid Width="13" Height="12" RenderTransform="1,0,0,1,0,1">
                                                    <Path Data="M0,6 L8,6 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                          Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2"  />
                                                </Grid>
                                            </Button.Content>
                                        </Button>
                                            <Button x:Name="Restore" Command="{Binding Source={x:Static SystemCommands.RestoreWindowCommand}}" ToolTip="{x:Static modernUi:Resources.Restore}" Style="{StaticResource SystemButton}" Visibility="Collapsed" >
                                                <Button.Content>
                                                    <Grid Width="13" Height="12" UseLayoutRounding="True" RenderTransform="1,0,0,1,.5,.5">
                                                        <Path Data="M2,0 L8,0 L8,6 M0,3 L6,3 M0,2 L6,2 L6,8 L0,8 Z" Width="8" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                              Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="1"  />
                                                    </Grid>
                                                </Button.Content>
                                            </Button>
                                            <Button x:Name="Maximize" Command="{Binding Source={x:Static SystemCommands.MaximizeWindowCommand}}" ToolTip="{x:Static modernUi:Resources.Maximize}" Style="{StaticResource SystemButton}" >
                                                <Button.Content>
                                                    <Grid Width="13" Height="12">
                                                        <Path Data="M0,1 L9,1 L9,8 L0,8 Z" Width="9" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                              Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2"  />
                                                    </Grid>
                                                </Button.Content>
                                            </Button>
                                            <Button x:Name="Close" Command="{Binding Source={x:Static SystemCommands.CloseWindowCommand}}" ToolTip="{x:Static modernUi:Resources.Close}" Style="{StaticResource SystemButton}" >
                                                <Button.Content>
                                                    <Grid Width="13" Height="12" RenderTransform="1,0,0,1,0,1">
                                                        <Path Data="M0,0 L8,7 M8,0 L0,7 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                          Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="1.5"  />
                                                    </Grid>
                                                </Button.Content>
                                            </Button>
                                    </StackPanel>
                                </Grid>


                                <!-- content frame -->
                                <mui:ModernFrame x:Name="ContentFrame" Grid.Row="3" Grid.RowSpan="2" Margin="42,8,16,16" Source="{Binding ContentSource, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" ContentLoader="{TemplateBinding ContentLoader}"/>

                                <!-- resize grip -->
                                <Grid Grid.Row="1" x:Name="ResizeGrip" Background="Transparent" Visibility="Collapsed" HorizontalAlignment="Right" VerticalAlignment="Bottom" WindowChrome.ResizeGripDirection="BottomRight">
                                    <Path Width="12" Height="12" Margin="1" 
                                          Stroke="{DynamicResource WindowText}"
                                          StrokeThickness="1"
                                          Stretch="None"
                                          Data="F1 M1,10 L3,10 M5,10 L7,10 M9,10 L11,10 M2,9 L2,11 M6,9 L6,11 M10,9 L10,11 M5,6 L7,6 M9,6 L11,6 M6,5 L6,7 M10,5 L10,7 M9,2 L11,2 M10,1 L10,3" />
                                </Grid>
                            </Grid>
                        </AdornerDecorator>
                    </Border>
                </Border>

                <ControlTemplate.Triggers>
                    <Trigger Property="IsActive" Value="True">
                        <Setter Property="BorderBrush" Value="{DynamicResource WindowBorderActive}" />
                    </Trigger>
                    <Trigger Property="WindowState" Value="Maximized">
                        <Setter TargetName="Maximize" Property="Visibility" Value="Collapsed" />
                        <Setter TargetName="Restore" Property="Visibility" Value="Visible" />
                        <Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
                    </Trigger>
                    <Trigger Property="WindowState" Value="Normal">
                        <Setter TargetName="Maximize" Property="Visibility" Value="Visible" />
                        <Setter TargetName="Restore" Property="Visibility" Value="Collapsed" />
                    </Trigger>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="ResizeMode" Value="CanResizeWithGrip" />
                            <Condition Property="WindowState" Value="Normal" />
                        </MultiTrigger.Conditions>
                        <Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
                    </MultiTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>

    <Setter Property="WindowChrome.WindowChrome">
        <Setter.Value>
            <WindowChrome CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False" NonClientFrameEdges="None" />
        </Setter.Value>
    </Setter>
</Style>

bobthiele avatar Aug 27 '15 04:08 bobthiele

I have been through this article and played around with the results. Currently I am using Version 3 of the ModernUI and have 65 errors when I try to compile. Does anyone have more detailed instructions on how to do this? I can't believe the arrow is so deeply embedded in the styles that I can't simply comment it out somewhere.

jeffki avatar Jan 25 '16 16:01 jeffki

@jeffki Are you just trying to only get rid of the button, or all navigation? If it's all navigation then the Modern Window form is what you want. There is a project for that as well.

bobthiele avatar Jan 26 '16 18:01 bobthiele

To get bobthiele's example code working, add ";assembly=FirstFloor.ModernUI" to the two namespace declarations that don't have it. They need to be there because we're referencing the mui binary rather than code.

jwrush avatar Mar 22 '16 16:03 jwrush

Here's example code with the namespaces corrected. Unlike the one above, this only removes the backbutton, not all of navigation.

ModifiedModernWindow.xaml.txt

jwrush avatar Mar 22 '16 16:03 jwrush

Where should I put these code to modify the theme?

inxy-n avatar Feb 16 '21 08:02 inxy-n