Click here to Skip to main content
15,867,453 members
Home / Discussions / WPF
   

WPF

 
QuestionDrive and File access in Silverlight??? Pin
MichaelGaudioso2-Nov-10 6:56
MichaelGaudioso2-Nov-10 6:56 
AnswerRe: Drive and File access in Silverlight??? Pin
Kunal Chowdhury «IN»2-Nov-10 9:12
professionalKunal Chowdhury «IN»2-Nov-10 9:12 
GeneralRe: Drive and File access in Silverlight??? Pin
MichaelGaudioso2-Nov-10 9:15
MichaelGaudioso2-Nov-10 9:15 
AnswerRe: Drive and File access in Silverlight??? Pin
Abhinav S2-Nov-10 17:35
Abhinav S2-Nov-10 17:35 
QuestionCrystal reports with WPF Pin
Kamal Gurnani31-Oct-10 21:02
Kamal Gurnani31-Oct-10 21:02 
AnswerRe: Crystal reports with WPF Pin
Mycroft Holmes31-Oct-10 23:23
professionalMycroft Holmes31-Oct-10 23:23 
AnswerRe: Crystal reports with WPF Pin
Abhinav S31-Oct-10 23:42
Abhinav S31-Oct-10 23:42 
QuestionTrivial data binding to member variables. Pin
Barry Lapthorn31-Oct-10 2:23
protectorBarry Lapthorn31-Oct-10 2:23 
Hi,

I've just created a trivial xaml window that databinds a textbox to a property:

<Window x:Class="WpfTests.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        x:Name="root">
    <StackPanel>
        <DockPanel>
            <Button DockPanel.Dock="Right" Height="23" Click="buttonTest_Click">Browse...</Button>
            <TextBox DockPanel.Dock="Left"
                Height="23" Margin="0,0,2,0" Name="textBoxFileName" 
                     Text="{Binding ElementName=root, Mode=TwoWay, Path=FileName}"/>
        </DockPanel>
        <DockPanel>
            <TextBlock DockPanel.Dock="Bottom" Text="{Binding ElementName=root, Mode=TwoWay, Path=FileName}"></TextBlock>
            <Button DockPanel.Dock="Bottom" Name="buttonToggle" Click="buttonToggle_Click">Toggle...</Button>
        </DockPanel>
    </StackPanel>
</Window>


And the (trivial) code behind:

namespace WpfTests
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register("FileName", typeof(string), typeof(MainWindow));

        public string FileName
        {
            get { return (string)GetValue(FileNameProperty); }
            set { SetValue(FileNameProperty, value); }
        }

        private void buttonTest_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog d = new Microsoft.Win32.OpenFileDialog();
            if (d.ShowDialog() == true)
                this.FileName = d.FileName;
        }

        private void buttonToggle_Click(object sender, RoutedEventArgs e)
        {
            this.FileName = "Toggle clicked.";
        }
    }
}


I have a couple of questions (that require simple 'assume-I-know-nothing' answers):

To date, this is the only trivial example I've found of binding the value of a control to a class property. Am I doing this the correct way, or is this something fundamental to databinding that I'm missing?

If, in VS2010, I go to the xaml view, select the 'Text' property of 'textBoxFileName' and 'Apply Data Binding', it auto-navigates itself to 'FileName' (that I set), but then hovering over the value 'FileName' the tooltip says 'Path item FileName cannot be resolved': should I be concerned, or is this just the xaml editor knowing nothing about the code behind? Or is there an error or flaw in the code or design?

Thanks in advance,

Barry.
Regards,

Barry

AnswerRe: Trivial data binding to member variables. Pin
venugopalm1-Nov-10 3:54
venugopalm1-Nov-10 3:54 
GeneralRe: Trivial data binding to member variables. Pin
Barry Lapthorn6-Nov-10 3:44
protectorBarry Lapthorn6-Nov-10 3:44 
QuestionRichtextbox databinding Pin
Mycroft Holmes30-Oct-10 0:16
professionalMycroft Holmes30-Oct-10 0:16 
AnswerRe: Richtextbox databinding Pin
Abhinav S30-Oct-10 18:26
Abhinav S30-Oct-10 18:26 
GeneralRe: Richtextbox databinding Pin
Mycroft Holmes30-Oct-10 20:38
professionalMycroft Holmes30-Oct-10 20:38 
GeneralRe: Richtextbox databinding Pin
Abhinav S30-Oct-10 23:52
Abhinav S30-Oct-10 23:52 
GeneralRe: Richtextbox databinding Pin
Mycroft Holmes2-Nov-10 12:26
professionalMycroft Holmes2-Nov-10 12:26 
QuestionXBAP Security Question and poking around for thoughts Pin
rwinte28-Oct-10 6:37
rwinte28-Oct-10 6:37 
QuestionWPF perfomance Pin
afsal qureshi28-Oct-10 3:17
afsal qureshi28-Oct-10 3:17 
AnswerRe: WPF perfomance Pin
RugbyLeague28-Oct-10 3:46
RugbyLeague28-Oct-10 3:46 
GeneralRe: WPF perfomance Pin
afsal qureshi28-Oct-10 5:09
afsal qureshi28-Oct-10 5:09 
GeneralRe: WPF perfomance Pin
Simon_Whale28-Oct-10 5:15
Simon_Whale28-Oct-10 5:15 
GeneralRe: WPF perfomance Pin
RugbyLeague28-Oct-10 5:23
RugbyLeague28-Oct-10 5:23 
GeneralRe: WPF perfomance Pin
afsal qureshi28-Oct-10 5:44
afsal qureshi28-Oct-10 5:44 
GeneralRe: WPF perfomance Pin
AspDotNetDev3-Nov-10 7:03
protectorAspDotNetDev3-Nov-10 7:03 
AnswerRe: WPF perfomance Pin
Pete O'Hanlon28-Oct-10 7:13
subeditorPete O'Hanlon28-Oct-10 7:13 
AnswerRe: WPF perfomance Pin
venugopalm1-Nov-10 18:46
venugopalm1-Nov-10 18: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.