Custom Control - Generic.baml file not generated
Hello. I'm having an issue with my custom control if I move it to an external library.
My custom control works fine if it is in the same assembly as the application but when I move it out to an external library my control does not appear. I noticed that within the app the generic.baml file was created but in the external library I do not see the generic.baml file. My build action for the file is set to Page.
Any ideas/suggestions would be greatly appreciated. Thanks!
Note, I have done the following steps below:
/// Step 1b) Using this custom control in a XAML file that exists in a different project.
/// Add this XmlNamespace attribute to the root element of the markup file where it is
/// to be used:
///
/// xmlns:MyNamespace="clr-namespace:ACPUi;assembly=ACPUi"
///
/// You will also need to add a project reference from the project where the XAML file lives
/// to this project and Rebuild to avoid compilation errors:
///
/// Right click on the target project in the Solution Explorer and
/// "Add Reference"->"Projects"->[Browse to and select this project]
[1202 byte] By [
mkfl] at [2007-12-22]
Yes. Thanks in advance.
Some additional information. Please advise if there's a known issue so I can proceed accordingly. Otherwise, I'm following the WPFSamplesApp and I'm not seeing what I've missed. I cannot determine why the baml file is not generated and from postings it seems like there is no longer a tool in which we can generate baml files manually.
CustomControl:
namespace
ACPUi{
public class UiNumericTextBoxSpin : Control static UiNumericTextBoxSpin(){
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.//This style is defined in themes\generic.xamlDefaultStyleKeyProperty.OverrideMetadata(
typeof(UiNumericTextBoxSpin), new FrameworkPropertyMetadata(typeof(UiNumericTextBoxSpin)));}
Style: (Build Action is Set to 'Page').
<
ResourceDictionaryxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:ACPUi">
<
Style TargetType="{x:Type local:UiNumericTextBoxSpin}"><
Setter Property="Template"><
Setter.Value><
ControlTemplate TargetType="{x:Type local:UiNumericTextBoxSpin}"><
Grid>Assembly Info:
[assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.SourceAssembly, System.Windows.ResourceDictionaryLocation.SourceAssembly)]
Test App: (I've included ACPUi as a reference into the Test App)
<
Window x:Class="ACPUiTempTestApp.Window1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:ACPUiNS="clr-namespace:ACPUi;assembly=ACPUi"Title="ACPUiTempTestApp" Height="429" Width="473">
<
StackPanel><
ACPUiNS:UiNumericTextBoxSpin></ACPUiNS:UiNumericTextBoxSpin>I haven't able to repro the problem you reported - which CTP build are you using? Above given code looks fine. If you dont have theme specific style, then you can set ResourceDictionaryLocation for that to none like given below
[assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)]
The inital project (before I attempted to create the custom control) was created when I had the Beta2 release. I've since upgraded to June CTP and attempted to add the custom control.
I decided to create a new project from scratch just to isolate the issue, I did exactly the same steps and the baml file is generated. So I guess I'm fine for now.
Thanks for your time.
mkfl wrote: |
| The inital project (before I attempted to create the custom control) was created when I had the Beta2 release. I've since upgraded to June CTP and attempted to add the custom control. I decided to create a new project from scratch just to isolate the issue, I did exactly the same steps and the baml file is generated. So I guess I'm fine for now. |
|
yeah, I noticed that, too - if you look into the .csproj file, the following line is missing (near the end):
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
Sam