|
Yup - as B is a dependency of A, it makes sense to validate it alongside as well.
|
|
|
|
|
Well, it works, but sometimes it doesn't. For instance, when I select the date on A with Ctrl+Arrow, and then type over it, sometimes the B field gets validated, sometimes it doesn't. But,hey, you can't have it all, right???
P.S: By the by, don't you just hate that?
public String Property
{
get
{
return _Property;
}
get
{
_Property=value;
RaisePropertyChanged("Property");
}
}
I wish there was some kind of "one-liner"! Something like:
ObservableProperty String MyProperty;
|
|
|
|
|
I created ths data template:
<DataTemplate DataType="{x:Type models:PartModel}">
<StackPanel Orientation="Vertical"
Margin="0,1,0,1">
<StackPanel Orientation="Horizontal">
<Image Source="/Abtech.Spares.UI;component/Media/Graphics/motherboard_enabled_96x96.png"
Height="16"
Width="16"
Margin="0,0,3,0"/>
<TextBlock Text="{Binding PartNumber}"></TextBlock>
<TextBlock Text="-"
Margin="3,0,3,0"/>
<TextBlock Text="{Binding PartDescription}"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label x:Name="lblTribal"
Content="Tribal"/>
<TextBox x:Name="txtTribal"
Text="{Binding Tribal}"
Width="100"/>
<Button x:Name="cmdTribal"
Command="{Binding SelectTribalCommand, Mode=TwoWay}"
Margin="2,0,0,0">
<StackPanel Orientation="Horizontal">
<Image Source="/Abtech.Spares.UI;component/Media/Graphics/Toolbar/search_16x16.png"
Margin="0,0,3,0"/>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
</DataTemplate>
At the bottom, how do I point the SelectTribalCommand to the data context, not the PartModel?
Everything makes sense in someone's mind
|
|
|
|
|
If you defined the DataTemplate in the resources section, I don't believe you can since there is no data context there. If you defined it in the regular section underneath the control, it may work as is or it may not . These things are sometimes try & pray. You often have to futz with the syntax to get it to work.
I'd try these things in this order:
1) try move the DataTemplate "inline" to the control
2) try use ElementName binding using the Window or UserControl, ie. ElementName=myWindow, Path=DataContext.SelectTribalCommand (you *may* need to use type casting here)
To do #2, you have to do #1 anyways, but I think that should work.
|
|
|
|
|
The machine I am using has :
Microsoft Silverlight
Version: 4.0.60831.0
(c) 2011 Microsoft Corporation. All rights reserved.
I have now created a silverlight project. On going to the properties of the silverlight project, it shows:
Target silverlight version : Silverlight 3
Should it not show silverlight 4? How can I get that in the drop down control please?
Thanks
|
|
|
|
|
Same reply as here[^].
The Silverlight 4 Tools for Visual Studio 2010 should add that option to Silverlight project properties.
Mark Salsbery
|
|
|
|
|
Please am trying to show the loaction of a file in my textbox but its not working. Thisi is my code is there some am during because am using WPF for the first time
Dim ofd As New Microsoft.Win32.OpenFileDialog
Dim strFileToOpen As string
ofd.FileName = ""
ofd.Title = "Choose a file to encrypt"
ofd.InitialDirectory = "C:\"
ofd.Filter = "All Files (*.*) | *.*"
If ofd.ShowDialog = Forms.DialogResult.OK Then
strFileToOpen = ofd.FileName
txtFileToOpen.Text = strFileToOpen
End If
Dammy
|
|
|
|
|
Put a breakpoint on the line strFileToOpen = ofd.FileName, and run the application in debug. Do whatever you need to do to get to the file dialog. When you hit the breakpoint (after clicking OK), take a look and see what's in ofd.FileName then step over the line. Check the value in strFileToOpen and then step over the txtFileToOpen.Text line. Again, see what's in that property.
|
|
|
|
|
in the property of the ofd.FileName shows the file and its location but the strFileToOpen is empty and in the propert of the ofd its showing that "No children available" in the CustomPlaces property
Dammy
modified 23-Nov-11 13:13pm.
|
|
|
|
|
strFileToOpen will not be set until you assign the value. Perform each step over exactly as I describe it.
|
|
|
|
|
so i did as u said and i got the error in this line
If ofd.ShowDialog = Forms.DialogResult.OK Then in the CustomPlaces the count was 0 and i could still open the dialog and the strFileToOpen property is nothing
|
|
|
|
|
OK, what error did you get? I'm not a VB.NET developer, so you're going to have to help me out here.
|
|
|
|
|
Never mind, I know what the problem is. Basically, you're attempting to assign an incompatible type back here. Dialogs return a nullable bool. What you want to do is:
Dim result? As Boolean = ofd.ShowDialog()
If result = True Then
|
|
|
|
|
thanks it worked
|
|
|
|
|
No problem, glad to be able to help.
|
|
|
|
|
Here is a common scenario:
The IsChecked property of each RadioButton in a group is bound to a custom Enum via an appropriate EnumToBoolean converter.In some other part of the view, a group of TextBoxes, Labels, whatnot, needs to be disabled or enabled according to the value of the Enum.Since the IsChecked property is already bound, I can't bind one more Boolean property to achieve the disabling/enabling.
Question: what would be the commonly accepted approach for the above scenario - preferably without a horde of Booleans scattered all over my code?
|
|
|
|
|
Why can't you just bind the controls IsEnabled property directly to the enum values using the same converter ? I ran a test scenario and it works fine.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Murphy's Law on Software Development:"The solution you're bashing your head to find,is the one daggling in front of your stupid nose!"
|
|
|
|
|
Aint that the truth !
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
as far as i know, we can not bind the collection<businessobject> to the TabControl.ItemSources directly. we need to convert the bussinessobject collection to tabitem collection first and bind them to the tabcontrol.itemssources.
Here comes the question
I can not binding the TabControl.SelectedItem to the SelectedBussinessObject.
If I do so like :
<controls:TabControl Name="tbcFactories" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding Mode=OneWay}"
ItemsSource="{Binding Path=Factories,Mode=OneWay, Converter={StaticResource FactorysToTabitemsConverter}}"
SelectedItem="{Binding Path=CurrentManuFactory, Mode=OneWay, Converter={StaticResource FactoryToTabitemConverter}}" TabStripPlacement="Left"</controls:TabControl>
>
I can bind the converted tabeitem collection to tabcontrol.itemssource. But the tab doesn't switch when I change the CurrentManuFactory,and what's more , the FactoryToTabitemConverter is not activated also.
I am sure the CurrentManuFactory is changed and notification is send.
Any tips ?
|
|
|
|
|
Mode=OneWay in the SelectedItem is causing the problem, i guess. Remove that and try.
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
You can bind a Tabcontrol to a collection of Business objects. I tried this as an excercise.
My Models
public class Factory
{
public string Name { get; set; }
}
public class Factories : ObservableCollection<Factory>
{
public Factories()
{
for (int i = 0; i < 5; i++)
{
Factory factory = new Factory() { Name = "Factory " + i.ToString() };
this.Add(factory);
}
}
}
My code behind:
public Factories AllFactories { get; set; }
Factory currentFactory;
public Factory CurrentFactory
{
get
{
return currentFactory;
}
set
{
currentFactory = value;
NotifyPropertyChanged("CurrentFactory");
}
}
public MainWindow()
{
InitializeComponent();
AllFactories = new Factories();
this.DataContext = this;
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(String info)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(info));
}
}
and
My XAML
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.Resources>
<DataTemplate DataType="{x:Type local:Factory}">
<TextBlock Text="{Binding Path=Name}"/>
</DataTemplate>
</Grid.Resources>
<ComboBox ItemsSource="{Binding Path=AllFactories}" SelectedItem="{Binding Path=CurrentFactory, Mode=TwoWay}"/>
<TabControl Name="tcMain" Grid.Row="1" DataContext="{Binding}" ItemsSource="{Binding Path=AllFactories}"
IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=CurrentFactory, Mode=TwoWay}">
<TabControl.ItemTemplate>
<DataTemplate>
<DockPanel >
<Label Content="{Binding Path=Name}" Margin="3"/>
</DockPanel>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
</Grid>
I bound a Combo to AllFactories as well as the TabControl to check whether if I select a factory it will change on the tab control, and it all works peachy. I am sure if you go through this, you will see where you are going wrong.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thank you ! I will have a try later.
Btw, Mine is Silverlight. your example is silverlight or WPF ?
|
|
|
|
|
It's WPF.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I have developed a theme in XAML. Then I built a class library project using that .xaml. The output dll is working fine as theme.
I want to add a messageBox as soon as this dll gets used, or whenever the application (which uses it) starts up. What would be the code? And where do I need to write it? Obviously, this DLL itself should have this code.
Few more clarifications:
I want standard message box to appear, as soon as any user runs the application with my theme dll. Something like 'This is unregistered version of the theme'. I want to know how and where can I write code for this, inside my class library project.
Please answer as if you are answering to a newbie.
modified 23-Nov-11 10:57am.
|
|
|
|