0
我有這個代碼來創建動態按鈕樣式基於從運行時生成的另一個類生成的點,我有這個異常 '無法創建未知類型'樣式''。行號「1」和行位置「2」。無法在WPF中創建未知類型'樣式'異常?
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);