은 내가WPF ResourceDictionary의 및 DynamicResource
아니라 내가 WPF 응용 프로그램을 프로그래밍을하고 ... WPF 새로운 그래서 어쩌면이 "멍청한 놈"질문이 될 것입니다하지만 난 그것에 대한 답변을 찾을 수없는 (그리고 너무 쉽게 보인다)입니다 그리고 나는 웹 페이지에 CSS와 비슷한 것을 사용하고 싶다. 그래서 ResourceDictionary를 발견하고 그것을 사용하려고 시도했다. ...
나는 Frame을 생성하고 클릭 할 때 UserControl이 같은 Frame에로드되는 메인 윈도우가있다 .I 내 메인 윈도우에 내 ResourceDictionary (root/style/Styles.xaml)를 다음과 같이 포함 시키십시오 :
<Window.Resources>
<ResourceDictionary x:Key="styles" Source="style/Styles.xaml" />
</Window.Resources>
이
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="ProductsRequired" TargetType="{x:Type Label}">
<Setter Property="Height" Value="28" />
...
내 메인 창에 그것을 사용하지 않는하지만 기본 창으로로드 내 된 UserControls에 사용하려는 그리고 난 이런 식으로 사용하려고 :하는 난이
<Label Name="product1" Style="{DynamicResource ProductsRequired}" />
경고 나는 항상 다음과 같은 메시지를 표시합니다. 리소스 "ProductsRequired"를 확인할 수 없습니다.
는 난 ... 내 UserControl을<UserControl.Resources>
<ResourceDictionary x:Key="styles" Source="../style/Styles.xaml" />
</UserControl.Resources>
아무것도 발생에 스타일을 포함하여 시도
그럼 내 질문 긴하지만 난 분명히하고 싶어
... :)P.S. 당신이 그것을 에 리소스를 추가해야하는 경우 모든 논리가 BTW
private ResourceDictionary myStyles = new ResourceDictionary();
Style ProductsRequired = myStyles["ProductsRequired"] as Style;
product1.Style = ProductsRequired;
확인 고맙습니다 내가 내가 그 전에했고, 지금 ... :(내가 누구인지 모르는하지 않는 것처럼 작동하지 않았다 – lanicor