Note that there are some explanatory texts on larger screens.

plurals
  1. POmysterious runtime error in applying a template to wpf window
    primarykey
    data
    text
    <p>i have a hard problem dealing with template. please help me.</p> <p><strong>App.xaml</strong></p> <pre><code>&lt;Application x:Class="WpfApplication1.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; //Note i didn't set a StartupURI in Application tag please. &lt;Application.Resources&gt; &lt;Style TargetType="Window" x:Key="myWindowStyle"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate&gt; &lt;Grid&gt; &lt;Rectangle Fill="gray" RadiusX="30" RadiusY="30"/&gt; &lt;ContentPresenter/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Application.Resources&gt; &lt;/Application&gt; </code></pre> <p><strong>App.xaml.cs</strong></p> <pre><code>using System; using System.Windows; namespace WpfApplication1 { public partial class App : Application { CMainWindow winMain; protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); winMain = new CMainWindow(); winMain.ShowDialog(); } } } </code></pre> <p><strong>CMainWindow.xaml</strong></p> <pre><code>&lt;Window x:Class="WpfApplication2.CMainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Style="{StaticResource myWindowStyle}" Background="Red"&gt; &lt;/Window&gt; </code></pre> <p>=====================</p> <p><strong>question #1</strong></p> <p>when run this program, ide occure a runtime error : XmlParseException. so i add a line in app.xaml, it runs properly. that line is : StartupUri="CMainWindow.xaml".</p> <p>what is this? what relationship between template and startupuri? please tell me about this.</p> <p><strong>question #2</strong></p> <p>when i add control to CMainWindow, it didn't apeear even i set a in window's template.</p> <p>how can i add control properly in this situation?</p> <p>thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload