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

User control issue in the app #47

Open
sumit-codebrewer opened this issue Feb 29, 2024 · 7 comments
Open

User control issue in the app #47

sumit-codebrewer opened this issue Feb 29, 2024 · 7 comments
Labels
question Further information is requested

Comments

@sumit-codebrewer
Copy link

sumit-codebrewer commented Feb 29, 2024

The library looks good on my application, it has several styles that are making my windows look modern. Like, this how I implemented a settings page in my app.

image

The issue is, when I am trying to enable the same modern styles on the user control, it is showing different behaviour. Like this is how the buttons are looking here.
image

image

Kindly suggest a way to fix the same, so that the user control have the same properties as a normal window.

@NotYoojun
Copy link
Member

Where did you put ThemeResource and XamlControlResource in?
They should be put in the App.Resources. Did you follow the Quick Start Guide?

@NotYoojun NotYoojun added the question Further information is requested label Mar 1, 2024
@sumit-codebrewer
Copy link
Author

I put that in app.xaml and it is applying the modern styles in every window. But talking about User control, it is not showing the same behaviour in this case.

Ideally, I want this kind of color in dark theme
image

What I am getting in case of user control being called in another window
image

Any ideas, how to fix this?

@biocross
Copy link

biocross commented Mar 2, 2024

I was able to get this to work for UserControl by manually merging resources for UserControl, and then forcing the style on the buttons:

<UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ui:ThemeResources />
                <ui:XamlControlsResources />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
<Button
Content="{Binding ButtonContent}"
Style="{StaticResource DefaultButtonStyle}">

@NotYoojun
Copy link
Member

I was able to get this to work for UserControl by manually merging resources for UserControl, and then forcing the style on the buttons:

<UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ui:ThemeResources />
                <ui:XamlControlsResources />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
<Button
Content="{Binding ButtonContent}"
Style="{StaticResource DefaultButtonStyle}">

I don't think this is a good idea. It will make the theme resources loaded twice.
What about adding those to DesignTimeResources?

@biocross
Copy link

biocross commented Mar 3, 2024

Any guides on how I can do this? Would really appreciate it - sorry I'm a little new to WPF development

@biocross
Copy link

biocross commented Mar 6, 2024

OK removing the UserControl.Resources and just manually specifying the style in the Button fixed the issue for me:

<Button
Content="{Binding ButtonContent}"
Style="{StaticResource DefaultButtonStyle}">

@NotYoojun
Copy link
Member

@biocross Maybe this solution is not bad.

However, in my scenario, everything works fine when adding themes into app.xaml.

I don't know why this doesn't work for you guys. I'm really confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants