Click here to Skip to main content
15,886,873 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: INotifyPropertyChanged and ObservableCollection question Pin
Pete O'Hanlon25-Feb-09 11:27
mvePete O'Hanlon25-Feb-09 11:27 
GeneralRe: INotifyPropertyChanged and ObservableCollection question Pin
BlitzPackage25-Feb-09 13:16
BlitzPackage25-Feb-09 13:16 
GeneralRe: INotifyPropertyChanged and ObservableCollection question Pin
Pete O'Hanlon25-Feb-09 21:31
mvePete O'Hanlon25-Feb-09 21:31 
QuestionNot able to set the default style for the controls with generic.xaml Pin
salon24-Feb-09 20:33
salon24-Feb-09 20:33 
AnswerRe: Not able to set the default style for the controls with generic.xaml Pin
Mark Salsbery25-Feb-09 10:16
Mark Salsbery25-Feb-09 10:16 
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
salon25-Feb-09 17:21
salon25-Feb-09 17:21 
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
Mark Salsbery25-Feb-09 21:20
Mark Salsbery25-Feb-09 21:20 
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
salon25-Feb-09 23:20
salon25-Feb-09 23:20 
My CS file is like this:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;



namespace MyCustomControls
{
    public class MyControl: ContentControl
    {
        public string Content1
        {
            get { return (string)GetValue(ContentProperty1); }
            set { SetValue(ContentProperty1, value); }
        }

        public static readonly DependencyProperty ContentProperty1 =
            DependencyProperty.RegisterAttached("Content", typeof(string), typeof(MyControl),
            new PropertyMetadata("a"));

        
        public MyControl()
            {
                this.DefaultStyleKey = typeof(MyControl);
            }
    }
}


Generic.xaml
<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyCustomControls;assembly=MyCustomControls">
    <Style TargetType="local:MyControl">
        <Setter Property="VerticalAlignment" Value="Bottom"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="VerticalAlignment" Value="Bottom"/>
        <Setter Property="Content" Value="The Code Project"/>
</ResourceDictionary>


and the xaml file of the user control where I want to use the above custom control
<UserControl x:Class="MyPortal.Controls.ctrlLogin"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="140"
    xmlns:local="clr-namespace:MyCustomControls;assembly=MyCustomControls">

<Grid x:Name="LayoutRoot" Width="400" Height="500" Background="Gray" HorizontalAlignment="Center">
        <Grid.RowDefinitions>
            <RowDefinition Height="20"/>
            <RowDefinition Height="480"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="400" />
        </Grid.ColumnDefinitions>
<local:MyControl Grid.Column="0" Grid.Row="0"/>
</Grid>

</UserControl>

None of the default property which is there in the generic.xaml file is reflected in the custom control.
If we put this property in the xaml file of user control itself then it works fine. But our requirement is to put the default value having styles or the content in generic.xaml
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
Mark Salsbery26-Feb-09 7:30
Mark Salsbery26-Feb-09 7:30 
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
salon26-Feb-09 17:47
salon26-Feb-09 17:47 
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
Derek Greer31-May-09 5:28
Derek Greer31-May-09 5:28 
GeneralRe: Not able to set the default style for the controls with generic.xaml Pin
salon31-May-09 18:11
salon31-May-09 18:11 
QuestionFill tab items with separated code Pin
Fredrik__24-Feb-09 12:32
Fredrik__24-Feb-09 12:32 
AnswerRe: Fill tab items with separated code Pin
Gideon Engelberth24-Feb-09 15:20
Gideon Engelberth24-Feb-09 15:20 
QuestionCan we use ASP.NET website inside the Silverlight application Pin
salon24-Feb-09 0:59
salon24-Feb-09 0:59 
AnswerRe: Can we use ASP.NET website inside the Silverlight application Pin
Michael Sync24-Feb-09 17:04
Michael Sync24-Feb-09 17:04 
AnswerRe: Can we use ASP.NET website inside the Silverlight application Pin
johnsontroye27-Feb-09 9:34
johnsontroye27-Feb-09 9:34 
GeneralRe: Can we use ASP.NET website inside the Silverlight application Pin
Ray Cassick5-Mar-09 4:51
Ray Cassick5-Mar-09 4:51 
GeneralRe: Can we use ASP.NET website inside the Silverlight application Pin
Braulio Dez12-Mar-09 23:03
Braulio Dez12-Mar-09 23:03 
Questionscroll ListBox to bottom in xaml Pin
ausadmin23-Feb-09 14:48
ausadmin23-Feb-09 14:48 
AnswerRe: scroll ListBox to bottom in xaml Pin
User 27100928-Feb-09 20:02
User 27100928-Feb-09 20:02 
QuestionCreate a TextBlock in Blend and Edit it in RunTime Pin
Smithy96323-Feb-09 8:19
Smithy96323-Feb-09 8:19 
AnswerRe: Create a TextBlock in Blend and Edit it in RunTime Pin
Thomas Stockwell23-Feb-09 15:55
professionalThomas Stockwell23-Feb-09 15:55 
QuestionWPF data templating / binding Pin
pym23-Feb-09 3:33
pym23-Feb-09 3:33 
AnswerRe: WPF data templating / binding Pin
ABitSmart23-Feb-09 4:46
ABitSmart23-Feb-09 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.