在ResourceDictionary文件中使用viewbox

我有ResourceFile1.xaml文件的内容

                ....   

PhoneAppplicationPage的代码

         

但这个代码不起作用。 Designer Error:InvalidOperationException:Element已经是另一个元素的子元素。 还有

更新0

我写了一个示例,它更改了取决于CheckBox值的模板。

转换器来更改模板:

 public class TemplateSelectorConverter : IValueConverter { public DataTemplate TrueTemplate { get; set; } public DataTemplate FalseTemplate { get; set; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (((bool) value)) return TrueTemplate; return FalseTemplate; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotSupportedException(); } } 

资源:

        

Xaml标记:

         

我希望这有帮助。

Interesting Posts