c# - Reference Main Window's Dictionary from Resource Dictionary -


मेरे पास एक WPF विंडो है:

  & lt; विंडो x: class = "MyUI मुख्य विन्डो "और इतने पर & gt; & LT; Window.Resources & gt; & LT; ResourceDictionary & gt; & Lt; शैली TargetType = "{x: प्रकार s: SurfaceListBox}" x: Key = "FatherStyle" & gt; & Lt; / ResourceDictionary & gt; & LT; /Window.Resources> & Lt; / विंडो & gt;   

मेरे पास MyResourceDictionary.xaml में एक संसाधन शब्दकोश है:

  & lt; संसाधनक्षेत्र xmlns = "...... ... "और इतने पर & gt; & Lt; शैली TargetType = "{x: प्रकार s: SurfaceListBox}" x: Key = "ChildStyle" BasedOn = "{StaticResource FatherStyle}" / & gt; & Lt; / ResourceDictionary & gt;   

लेकिन जब मैं ChildStyle से MyUI.Window संदर्भित करने का प्रयास करता हूं:

  & lt; विंडो जैसा कि ऊपर कोड के 1 ब्लॉक में दिखाया गया है & gt; & Lt; s: SurfaceListBox Style = "{StaticResource ResourceKey = ChildStyle}" / & gt; & Lt; / विंडो & gt;   

यह मुझसे कहता है कि उसे पिता शैली नहीं मिल सकता है मैंने MyResourceDictionary.xaml में शब्दकोश पढ़ा और मिला दिया:

  & lt; संसाधन उपकरण xmlns = "........." और इतने पर & gt; & LT; ResourceDictionary.MergedDictionaries & gt; & Lt; संसाधन स्रोत स्रोत = "मेन वांडो। एक्सएमएल" / & gt; & LT; /ResourceDictionary.MergedDictionaries> & Lt; स्टाइल बाल शैली, जैसा ऊपर दिखाया गया है & gt; & Lt; / ResourceDictionary & gt;   

अब यह मुझे बताता है कि उसे बाल शैली नहीं मिल सकता है मैं इसे ठीक से संदर्भ कैसे कर सकता हूं?

आप किसी विंडो-प्रकार में मौजूद एक संसाधन शब्दकोश का संदर्भ नहीं दे सकते XAML फ़ाइल, किसी अन्य फ़ाइल से आपको क्या करने की आवश्यकता है एक अलग संसाधन शब्दकोश, "Shared.xaml" या जो कुछ भी बना है:

  & lt; ResourceDictionary ... & gt; & Lt; शैली TargetType = "{x: प्रकार s: SurfaceListBox}" x: Key = "FatherStyle" & gt; & Lt; / ResourceDictionary & gt;   

अब अपनी मुख्य विंडो से साझा एक का संदर्भ लें:

... और "MyResourceDictionary.xaml" से भी:

  & lt; संसाधन उपकरण xmlns = "........." और इतने पर & gt; & LT; ResourceDictionary.MergedDictionaries & gt; & Lt; संसाधन स्रोत स्रोत = "साझा किया गया। एक्सएमएल" / & gt; & LT; /ResourceDictionary.MergedDictionaries> & Lt; शैली TargetType = "{x: प्रकार s: SurfaceListBox}" x: Key = "ChildStyle" BasedOn = "{StaticResource FatherStyle}" / & gt; & Lt; / ResourceDictionary & gt;   

और अब अपनी "MyUI.xaml" विंडो में, आपको "MyResourceDictionary" को संदर्भित करके "ChildStyle" तक पहुंचने में सक्षम होना चाहिए:

 < कोड> & lt; संसाधन उपकरण xmlns = "........." और इतने पर & gt; & LT; ResourceDictionary.MergedDictionaries & gt; & Lt; संसाधन स्रोत स्रोत = "MyResourceDictionary.xaml" / & gt; & LT; /ResourceDictionary.MergedDictionaries> & Lt; s: SurfaceListBox Style = "{StaticResource ResourceKey = ChildStyle}" / & gt; & Lt; / ResourceDictionary & gt;    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -