Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to reuse the Style of parent user control on child/sub user control in WPF/XAML

$
0
0

Friends,

I have a WPF user control/window which has a Style for textbox,  and  there is a another user control called inside the first user control ( parent ), I want to reuse the same style on the resource section of 2nd user control that is located in the 1st user control,  for example below is dummy code structure.

<UserControl....><UserControl.Resources><Style x:key="s" x:TargetType="{x:Type TextBox...> ....</Style></UserControl.Resources><Grid> ....<AnotherUserControl.../> </Grid> .. ..</UserControl><AnotherUserControl..><AnotherUserControl.Resources><DataTemplate....><StackPanel><TextBox Style="{StaticResource s}" // HOW TO USE style 's' here ???</StackPanel></DataTemplate></AnotherUserControl.Resources></AnotherUserControl>

As shown in the sample code, anyone has any idea how to use Style 's' on AnotherUserControl that is in parent user control ? Thanks.


Thanks - Ravi



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>