Link to home
Start Free TrialLog in
Avatar of Steve Hougom
Steve HougomFlag for United States of America

asked on

how to test code in a wpf user control library

Im trying to figure out how to debug some code I created in a wpf user control library.

Because wpf user control libraries have no startup object Im not sure how to step into my code.

User generated image
The code is a simple validation of a text box.

User generated image
I just want some way to invoke it.  Maybe a windows form with a button and a text box that references it and calls it.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Create a WPF application project, add a reference to your other project and then you will be able to test it.
ASKER CERTIFIED SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Hougom

ASKER

I added a windows form project to mine and Im trying to figure out how to invoke it.

Here is what my solution explorer looks like now.
 User generated image

Im just using a form1 button click to attempt to invoke my validation.  Im just not sure how to code the object that allows me to step through my validation.cs in the referenced project.
 
User generated image
Here is a button click event that I would like to use invoke the validation class in validation.cs.  Im just not sure how to code it.
Here is the validation.cs file in my wpf user control library project.

User generated image




Here is the xaml from the user control.

<UserControl x:Class="SoftwareAssetFormValidationControl.ValidationControl"            
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"            
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"            
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"            
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"            
             mc:Ignorable="d"            
             Visibility="Collapsed"            
             Width="Auto" Height="Auto" DataContextChanged="FormControl_DataContextChanged" >
    <Grid Height="Auto" Width="Auto">
        <TextBox Height="0" Margin="0,0,0,0" Name="textId" VerticalAlignment="Top" Width="0" Text="{Binding Path=$Id$, Mode=OneWay}" Visibility="Collapsed" />
    </Grid>
</UserControl>