Click here to Skip to main content
15,887,267 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF ComboBox Selected Item Problem Pin
Kevin Marois8-Dec-12 19:37
professionalKevin Marois8-Dec-12 19:37 
GeneralRe: WPF ComboBox Selected Item Problem Pin
Wayne Gaylard8-Dec-12 19:39
professionalWayne Gaylard8-Dec-12 19:39 
QuestionAt commands Pin
Pranay Dabholkar7-Dec-12 5:56
Pranay Dabholkar7-Dec-12 5:56 
AnswerRe: At commands Pin
Abhinav S9-Dec-12 20:14
Abhinav S9-Dec-12 20:14 
QuestionCurrency Converter Pin
pjank427-Dec-12 5:44
pjank427-Dec-12 5:44 
AnswerRe: Currency Converter Pin
Pete O'Hanlon7-Dec-12 6:58
mvePete O'Hanlon7-Dec-12 6:58 
GeneralRe: Currency Converter Pin
pjank427-Dec-12 7:38
pjank427-Dec-12 7:38 
QuestionWPF Binding TextBox to Dependency Property Pin
g_ap5-Dec-12 1:02
g_ap5-Dec-12 1:02 
I'm trying to create a single control (Ratings) with a Textblock and a Dependency property

Ratings.XAML:
XML
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:TestControl"
	mc:Ignorable="d"
	x:Class="TestControl.Ratings"
	x:Name="UserControl"
	d:DesignWidth="640" d:DesignHeight="480">

    <Grid x:Name="LayoutRoot">
        <TextBlock x:Name="RatingText" Text="{Binding Score}" Height="60" Margin="180,157,381,0" TextWrapping="Wrap" VerticalAlignment="Top"/>
    </Grid>
</UserControl>


and Ratings.xaml.cs:
C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TestControl
{
	public partial class Ratings : UserControl
	{
		public Ratings()
		{
			this.InitializeComponent();
		}
        public static readonly DependencyProperty ScoreProperty = DependencyProperty.Register( "Score", typeof(int), typeof(Ratings), new FrameworkPropertyMetadata(1));
        public int Score
            {
                get { return (int)GetValue(ScoreProperty); }
                set { SetValue(ScoreProperty, value); }
            }
	}
}


Then I'm trying to call it from a project changing the Dependency Parameter

XAML:
XML
<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:TestControl"
	x:Class="TestControl.MainWindow"
	x:Name="Window"
	Title="MainWindow"
	Width="640" Height="480">

	<Grid x:Name="LayoutRoot">
		<local:Ratings Score="20" Height="120" Margin="96,51,292,0" VerticalAlignment="Top"/>
	</Grid>
</Window>


and cs:
C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace TestControl
{
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			this.InitializeComponent();
		}
	}
}


But it isn't working!!! Can someone please tell me why???
AnswerRe: WPF Binding TextBox to Dependency Property Pin
Richard Deeming5-Dec-12 2:53
mveRichard Deeming5-Dec-12 2:53 
Questionhighlight list view - is--moueOver Pin
dominioYP3-Dec-12 10:07
dominioYP3-Dec-12 10:07 
AnswerRe: highlight list view - is--moueOver Pin
SledgeHammer013-Dec-12 11:52
SledgeHammer013-Dec-12 11:52 
QuestionWPF DrawingContext DrawText bug??? Pin
subakaev2-Dec-12 21:09
subakaev2-Dec-12 21:09 
GeneralRe: WPF DrawingContext DrawText bug??? Pin
TheIndra23-Nov-20 12:34
TheIndra23-Nov-20 12:34 
QuestionHow do you stop a WebBrowser object in WPF? Pin
Xarzu2-Dec-12 4:25
Xarzu2-Dec-12 4:25 
AnswerRe: How do you stop a WebBrowser object in WPF? Pin
Richard MacCutchan2-Dec-12 4:54
mveRichard MacCutchan2-Dec-12 4:54 
QuestionHow do you stop a WebBrowser object in WPF? Pin
Xarzu2-Dec-12 3:53
Xarzu2-Dec-12 3:53 
QuestionFlowDocument - different coloured text in a word Pin
RugbyLeague30-Nov-12 1:04
RugbyLeague30-Nov-12 1:04 
AnswerRe: FlowDocument - different coloured text in a word Pin
Pete O'Hanlon30-Nov-12 1:33
mvePete O'Hanlon30-Nov-12 1:33 
GeneralRe: FlowDocument - different coloured text in a word Pin
RugbyLeague30-Nov-12 1:50
RugbyLeague30-Nov-12 1:50 
AnswerRe: FlowDocument - different coloured text in a word Pin
Matt T Heffron30-Nov-12 7:46
professionalMatt T Heffron30-Nov-12 7:46 
GeneralRe: FlowDocument - different coloured text in a word Pin
RugbyLeague30-Nov-12 8:41
RugbyLeague30-Nov-12 8:41 
AnswerRe: FlowDocument - different coloured text in a word Pin
Matt T Heffron30-Nov-12 8:45
professionalMatt T Heffron30-Nov-12 8:45 
GeneralRe: FlowDocument - different coloured text in a word Pin
RugbyLeague30-Nov-12 8:48
RugbyLeague30-Nov-12 8:48 
GeneralRe: FlowDocument - different coloured text in a word Pin
RugbyLeague30-Nov-12 8:49
RugbyLeague30-Nov-12 8:49 
QuestionGrid.ColumnDefinition.setvalue Pin
caradri28-Nov-12 3:06
caradri28-Nov-12 3:06 

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.