how to load my style file instead of generic.xaml while applying style in window wpf











up vote
-1
down vote

favorite












I have WPF project, in which i have applied style from another assembly in window for entire application. But, one of my custom control which is used inside the application doesn't take the style. It's style get always loaded from generic.xaml.



In this custom control class, I have set the DefaultStyleKey property and also the external style file gets added in merged dictionary of Application's resource dictionary. Can anyone face this kind of issue?



Note: Style for other controls gets applied from another aasembly



<Window x:Class="WpfApplication_CalenderEdit.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:local="clr-namespace:WpfApplication_CalenderEdit"
xmlns:thirdParty=""
mc:Ignorable="d" thirdParty.Style="ThemeNew"
xmlns:ie="http://schemas.microsoft.com/expression/2010/interactivity"
WindowStartupLocation="CenterScreen"
Title="Calendar Sample" Height="450" Width="625" >
<!--<Window.DataContext>
<local:ViewModel/>

</Window.DataContext>-->
<Grid >
<!--<DockPanel>-->
<StackPanel >

<Calendar WeekNumberForeground="Red" Padding="10" />
<ComboBox Margin="20" Height="35" Width="150"/>
</StackPanel>









share|improve this question
























  • How did you "appy the style from another assembly in window for entire application"? Do the same for the custom control.
    – mm8
    Nov 7 at 12:51










  • I have my theme file in third party library. I included it's assembly in my project and setting style globally in window
    – Keerthana
    Nov 8 at 6:19















up vote
-1
down vote

favorite












I have WPF project, in which i have applied style from another assembly in window for entire application. But, one of my custom control which is used inside the application doesn't take the style. It's style get always loaded from generic.xaml.



In this custom control class, I have set the DefaultStyleKey property and also the external style file gets added in merged dictionary of Application's resource dictionary. Can anyone face this kind of issue?



Note: Style for other controls gets applied from another aasembly



<Window x:Class="WpfApplication_CalenderEdit.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:local="clr-namespace:WpfApplication_CalenderEdit"
xmlns:thirdParty=""
mc:Ignorable="d" thirdParty.Style="ThemeNew"
xmlns:ie="http://schemas.microsoft.com/expression/2010/interactivity"
WindowStartupLocation="CenterScreen"
Title="Calendar Sample" Height="450" Width="625" >
<!--<Window.DataContext>
<local:ViewModel/>

</Window.DataContext>-->
<Grid >
<!--<DockPanel>-->
<StackPanel >

<Calendar WeekNumberForeground="Red" Padding="10" />
<ComboBox Margin="20" Height="35" Width="150"/>
</StackPanel>









share|improve this question
























  • How did you "appy the style from another assembly in window for entire application"? Do the same for the custom control.
    – mm8
    Nov 7 at 12:51










  • I have my theme file in third party library. I included it's assembly in my project and setting style globally in window
    – Keerthana
    Nov 8 at 6:19













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have WPF project, in which i have applied style from another assembly in window for entire application. But, one of my custom control which is used inside the application doesn't take the style. It's style get always loaded from generic.xaml.



In this custom control class, I have set the DefaultStyleKey property and also the external style file gets added in merged dictionary of Application's resource dictionary. Can anyone face this kind of issue?



Note: Style for other controls gets applied from another aasembly



<Window x:Class="WpfApplication_CalenderEdit.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:local="clr-namespace:WpfApplication_CalenderEdit"
xmlns:thirdParty=""
mc:Ignorable="d" thirdParty.Style="ThemeNew"
xmlns:ie="http://schemas.microsoft.com/expression/2010/interactivity"
WindowStartupLocation="CenterScreen"
Title="Calendar Sample" Height="450" Width="625" >
<!--<Window.DataContext>
<local:ViewModel/>

</Window.DataContext>-->
<Grid >
<!--<DockPanel>-->
<StackPanel >

<Calendar WeekNumberForeground="Red" Padding="10" />
<ComboBox Margin="20" Height="35" Width="150"/>
</StackPanel>









share|improve this question















I have WPF project, in which i have applied style from another assembly in window for entire application. But, one of my custom control which is used inside the application doesn't take the style. It's style get always loaded from generic.xaml.



In this custom control class, I have set the DefaultStyleKey property and also the external style file gets added in merged dictionary of Application's resource dictionary. Can anyone face this kind of issue?



Note: Style for other controls gets applied from another aasembly



<Window x:Class="WpfApplication_CalenderEdit.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:local="clr-namespace:WpfApplication_CalenderEdit"
xmlns:thirdParty=""
mc:Ignorable="d" thirdParty.Style="ThemeNew"
xmlns:ie="http://schemas.microsoft.com/expression/2010/interactivity"
WindowStartupLocation="CenterScreen"
Title="Calendar Sample" Height="450" Width="625" >
<!--<Window.DataContext>
<local:ViewModel/>

</Window.DataContext>-->
<Grid >
<!--<DockPanel>-->
<StackPanel >

<Calendar WeekNumberForeground="Red" Padding="10" />
<ComboBox Margin="20" Height="35" Width="150"/>
</StackPanel>






wpf styles themes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 8:44

























asked Nov 7 at 9:10









Keerthana

484




484












  • How did you "appy the style from another assembly in window for entire application"? Do the same for the custom control.
    – mm8
    Nov 7 at 12:51










  • I have my theme file in third party library. I included it's assembly in my project and setting style globally in window
    – Keerthana
    Nov 8 at 6:19


















  • How did you "appy the style from another assembly in window for entire application"? Do the same for the custom control.
    – mm8
    Nov 7 at 12:51










  • I have my theme file in third party library. I included it's assembly in my project and setting style globally in window
    – Keerthana
    Nov 8 at 6:19
















How did you "appy the style from another assembly in window for entire application"? Do the same for the custom control.
– mm8
Nov 7 at 12:51




How did you "appy the style from another assembly in window for entire application"? Do the same for the custom control.
– mm8
Nov 7 at 12:51












I have my theme file in third party library. I included it's assembly in my project and setting style globally in window
– Keerthana
Nov 8 at 6:19




I have my theme file in third party library. I included it's assembly in my project and setting style globally in window
– Keerthana
Nov 8 at 6:19












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You should explicitly apply the same Style also for your custom window, e.g.:



<Style TargetType="{x:Type Window}" BasedOn="{StaticResource CustomStyle}" />
<Style TargetType="{x:Type controls:CustomWindow}" BasedOn="{StaticResource CustomStyle}" />





share|improve this answer





















  • Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
    – Keerthana
    Nov 8 at 6:20






  • 1




    @Keerthana: Please post your XAML to clarify your issue.
    – mm8
    Nov 8 at 8:10










  • posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
    – Keerthana
    Nov 8 at 8:44













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186377%2fhow-to-load-my-style-file-instead-of-generic-xaml-while-applying-style-in-window%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You should explicitly apply the same Style also for your custom window, e.g.:



<Style TargetType="{x:Type Window}" BasedOn="{StaticResource CustomStyle}" />
<Style TargetType="{x:Type controls:CustomWindow}" BasedOn="{StaticResource CustomStyle}" />





share|improve this answer





















  • Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
    – Keerthana
    Nov 8 at 6:20






  • 1




    @Keerthana: Please post your XAML to clarify your issue.
    – mm8
    Nov 8 at 8:10










  • posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
    – Keerthana
    Nov 8 at 8:44

















up vote
0
down vote













You should explicitly apply the same Style also for your custom window, e.g.:



<Style TargetType="{x:Type Window}" BasedOn="{StaticResource CustomStyle}" />
<Style TargetType="{x:Type controls:CustomWindow}" BasedOn="{StaticResource CustomStyle}" />





share|improve this answer





















  • Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
    – Keerthana
    Nov 8 at 6:20






  • 1




    @Keerthana: Please post your XAML to clarify your issue.
    – mm8
    Nov 8 at 8:10










  • posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
    – Keerthana
    Nov 8 at 8:44















up vote
0
down vote










up vote
0
down vote









You should explicitly apply the same Style also for your custom window, e.g.:



<Style TargetType="{x:Type Window}" BasedOn="{StaticResource CustomStyle}" />
<Style TargetType="{x:Type controls:CustomWindow}" BasedOn="{StaticResource CustomStyle}" />





share|improve this answer












You should explicitly apply the same Style also for your custom window, e.g.:



<Style TargetType="{x:Type Window}" BasedOn="{StaticResource CustomStyle}" />
<Style TargetType="{x:Type controls:CustomWindow}" BasedOn="{StaticResource CustomStyle}" />






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 7 at 12:53









mm8

79.1k81731




79.1k81731












  • Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
    – Keerthana
    Nov 8 at 6:20






  • 1




    @Keerthana: Please post your XAML to clarify your issue.
    – mm8
    Nov 8 at 8:10










  • posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
    – Keerthana
    Nov 8 at 8:44




















  • Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
    – Keerthana
    Nov 8 at 6:20






  • 1




    @Keerthana: Please post your XAML to clarify your issue.
    – mm8
    Nov 8 at 8:10










  • posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
    – Keerthana
    Nov 8 at 8:44


















Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
– Keerthana
Nov 8 at 6:20




Am not using custom window, I have set style in the window from which style get applied to all the controls defined inside the window
– Keerthana
Nov 8 at 6:20




1




1




@Keerthana: Please post your XAML to clarify your issue.
– mm8
Nov 8 at 8:10




@Keerthana: Please post your XAML to clarify your issue.
– mm8
Nov 8 at 8:10












posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
– Keerthana
Nov 8 at 8:44






posted the xaml code, also style gets applied when it is set directly to the control example: <Calendar thridParty="ThemeNew"/>
– Keerthana
Nov 8 at 8:44




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186377%2fhow-to-load-my-style-file-instead-of-generic-xaml-while-applying-style-in-window%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings