मैं वास्तव में WPF कस्टम कंट्रोल लाइब्रेरी से अन्य फ़ाइल से WPF स्टाइल लोड करने का प्रयास कर रहा हूं लेकिन मैं यहां लोड करने में विफल रहा हूं मेरा समाधान है।संसाधन फ़ाइल से WPF स्टाइल लोड हो रहा है
समाधान दो परियोजनाओं
प्रकार WPF कस्टम नियंत्रण पुस्तकालयप्रकार के WpfTestApp WPF आवेदन लाइब्रेरी के
WpfTestControls जो WpfTestControls के संदर्भ में है शामिल
MainWindow.xaml डब्ल्यूपीएफ एप्लीकेशन लाइब्रेरी से
<Window.Resources>
<Style x:Key="TempStyle" TargetType="{x:Type TextBox}">
<Setter Property="BorderBrush" Value="Green"/>
</Style>
</Window.Resources>
<Grid>
<TextBox Height="50px" Width="100px" Style="{DynamicResource TempStyle}"/>
</Grid>
Generic.xaml WPF से कस्टम नियंत्रण पुस्तकालय
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WpfTestControls;component/TextBoxStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
TextBoxStyle.xaml WPF से कस्टम नियंत्रण पुस्तकालय
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="TempStyle" TargetType="{x:Type TextBox}">
<Setter Property="BorderBrush" Value="Green"/>
</Style>
मेरे AssemblyInfo.cs फ़ाइल निम्नलिखित
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries))]
शामिल लेकिन फिर भी मैं शैली लोड करने में नाकाम रहने रहा हूँ। तो मैं उपयोग कर रहा हूँ Generic.xaml सब कुछ काम अच्छा उदाहरण के लिए अपेक्षा के अनुरूप
<Window x:Class="WpfTestApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="TempStyle" TargetType="{x:Type TextBox}">
<Setter Property="BorderBrush" Value="Green"/>
</Style>
</Window.Resources>
<Grid>
<TextBox Height="50px" Width="100px" Style="{StaticResource TempStyle}"/>
</Grid>
क्या मैं गलत कर रहा हूँ निम्नलिखित कोड काम करता है का उपयोग नहीं? अग्रिम
हाय हो सकता है कि मैंने इसे गलत लिखा लेकिन समाधान में केवल दो परियोजनाएं हैं जो टाइप डब्लूपीएफ कस्टम कंट्रोल लाइब्रेरी के WpfTestControls, और टाइप Wpf एप्लिकेशन के WpfTestApp में दो WpfTestControls संदर्भित हैं। – Robob
ठीक है तो मेरा संपादन ऊपर देखें ... –
आप सही हैं लेकिन जैसा कि मुझे लगता है कि यह पिछले समाधान के साथ काम करना चाहिए। यह कामकाज है जिसे मैं अभी अपनाना चाहता हूं – Robob