Autor Beitrag
alegria
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 79



BeitragVerfasst: Fr 18.03.11 11:18 
Hey!

Ich bekomme es einfach nicht hin aus den Resources heraus ein Databinding zu erzeugen...

XAML:
ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
<UserControl x:Class="SilverlightApplication.MainPage"
    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:SilverlightApplication;assembly=SilverlightApplication"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <UserControl.DataContext>
        <local:ViewModel />
    </UserControl.DataContext>

    <UserControl.Resources>
        <Style x:Name="myRedColor" TargetType="TextBlock">
            <Setter Property="Foreground" Value="Red"></Setter>
            <!--<Setter Property="Foreground" Value="{Binding vmColor}"></Setter>-->
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock Text="{Binding vmText}" Style="{StaticResource myRedColor}"></TextBlock>
    </Grid>
    
</UserControl>


ViewModel.cs
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
using System.Windows.Media;

namespace SilverlightApplication
{
    public class ViewModel
    {
        public string vmText { get { return "Lorem Ipsum..."; } }
        //public Color vmColor { get { return Colors.Red; } }
        public Brush vmColor { get { return new SolidColorBrush(Colors.Red); } }
    }
}


Kann jemand weiterhelfen???
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Fr 18.03.11 12:12 

_________________
>λ=
alegria Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 79



BeitragVerfasst: Fr 18.03.11 16:25 
wie schade... Aber danke für die Info!