0

我有这段代码可以根据在运行时生成的另一个类的生成点创建动态按钮样式,并且我有这个异常'无法创建未知类型'样式'。行号“1”和行位置“2”。

string s = "<Style xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Key=\"Mystyle\" TargetType=\"Button\">" +
        "<Setter Property=\"Template\">" +
            "<Setter.Value>" +
              "  <ControlTemplate TargetType=\"{x:Type Button}\">" +
                   " <Grid >" +
                           " <Polygon  Points=\""+points+" Fill=\"{TemplateBinding Background}\"" +
                         "Stroke=\"{TemplateBinding BorderBrush}\" DataContext=\"{Binding}\" />" +
                       " <ContentPresenter HorizontalAlignment=\"Center\"" +
                                   "   VerticalAlignment=\"Center\"/>" +
                   " </Grid>" +
              "  </ControlTemplate>" +
           " </Setter.Value>" +
    "    </Setter>" +
   " </Style>";
        StringReader stringReader = new StringReader(s);
        XmlReader xmlReader = XmlReader.Create(stringReader);
        Style  readerLoadButton = (Style)XamlReader.Load(xmlReader);
4

1 回答 1

3

尝试添加命名空间信息......

于 2012-07-24T17:02:02.313 回答