Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No App xml error #49

Open
pp111 opened this issue Mar 4, 2024 · 2 comments
Open

No App xml error #49

pp111 opened this issue Mar 4, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@pp111
Copy link

pp111 commented Mar 4, 2024

I need to use the library without an App.xaml

I used the sample project NoAppXaml as a reference. So the library resources are added in Window.Resources

The sample works fine, however if I add a NavigationView to the sample project window the application crashes with a NullReferenceException at

iNKORE.UI.WPF.Converters.CornerRadiusFilterConverter.Convert(object, System.Type, object, System.Globalization.CultureInfo)

This is the modified MainWindow.xaml that makes the application to crash:

<Window x:Class="NoAppXamlTest.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:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
        xmlns:local="clr-namespace:NoAppXamlTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ui:ThemeResources/>
                <ui:XamlControlsResources/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <StackPanel>
        <ui:NavigationView
            x:Name="navigation1"
            Height="460"
            Header="This is Header Text"
            IsBackButtonVisible="Collapsed"
            IsFooterSeparatorVisible="True"
            IsSettingsVisible="False"
            IsTabStop="False"
            PaneDisplayMode="Top"
            >
        </ui:NavigationView>
        <Button Content="test" VerticalAlignment="Top" HorizontalAlignment="Left"/>
        <CheckBox/>
    </StackPanel>
</Window>

It seems that some resources (CornerRadius) are not loaded, but I can't guess where is the problem.

@whitesong1
Copy link

whitesong1 commented Mar 6, 2024

I also encountered the same problem.

I want use many ui lib in my project so I don't want all pages to be overwritten with default styles by a certain library.

but i will get the error "Object reference not set to an instance of an object."when i use the
navigation control .
and if i join the code"<ink:ThemeResources />
<ink:XamlControlsResources />" to app.xaml, the error will be disappear.

this is my code:

error:

<Application x:Class="*.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:*"
             Startup="Application_Startup">

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="./Style/Shell/ShellStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

<Window x:Class="*.Shell"
        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:ink="http://schemas.inkore.net/lib/ui/wpf/modern"
        xmlns:local="clr-namespace:*"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="Shell"
        Width="1080"
        Height="650"
        d:DataContext="{d:DesignInstance Type=local:ShellViewModel,
                                         IsDesignTimeCreatable=True}"
        Background="#F3F3F3"
        mc:Ignorable="d">
    <Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.CheckBox.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
            <ResourceDictionary Source="pack://application:,,,/ClouldMusic.Shell;component/Dictionary/ShellDictionary.xaml" />
            <ink:ThemeResources />
            <ink:XamlControlsResources />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

    <Grid>
 >>       <ink:NavigationView />
    </Grid>
</Window>

I don`t konw how to slove the question.

@NotYoojun
Copy link
Member

It seems that conflicts may happen when using multiple ui libraries at the same time.

Sadly, the solution may vary when you are using different ui libraries. I'm in the weeds these days for web development and have no time to look into this.

We tried something to fix the null reference exception. But the results you provided proved my fix didn't work, I have no idea why.

@NotYoojun NotYoojun added bug Something isn't working help wanted Extra attention is needed labels Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants