I have a DataGrid with a DataGridCheckBoxColumn using Multibinding. The code compiles and works just as expected BUT intellisense in the XAML editor stops working as soon as I use the Path keyword in the markup.. It only stops for everything past the Binding tags but works prior to that:
<DataGridCheckBoxColumn x:Name="colIssues" Width="sizetoheader" Header="Issues" >
<DataGridCheckBoxColumn.Binding>
<MultiBinding Converter="{StaticResource MultiBooleanConverter}">
<Binding Path="Level"/>
<Binding Path="Weeping" />
</MultiBinding>
</DataGridCheckBoxColumn.Binding>
</DataGridCheckBoxColumn>
BEFORE
AFTER now intellisense has disappeared
Related
I am using an xceed DataGrid but I don't believe that matters here. What I need is how to get the databinding correct. I have a DataGrid column as follows:
<xcdg:Column FieldName="TestFieldValue"
Visible="False" Title="TestTitle"
GroupValueTemplate="{StaticResource TestFieldGroupTemplate}"/>
I am using a DataTemplate as follows:
<DataTemplate DataType="{x:Type testNamespace:TestFieldRecord}"
x:Key="TestFieldGroupTemplate">
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type xcdg:DataRow}},
Path=DataContext,
Converter={StaticResource TestFieldValueConverter}}" />
</DataTemplate>
First off, the value the property tied to this column field is just a long. The DataType here on the DataTemplate is actually the parent class of the column field property. An odd thing is if I just bind the text property in the data template like Text={Binding Converter={StaticResource TestFieldValueConverter}}, the converter still gets hit but with the long value from the column.
What I need here is to either bind to the DataRow's context, or to the the parent of the column TestFieldValue, which is the testNamespace:TestFieldRecord. Any find ancestor attempts have led me to no longer hitting my converter.
I think you need to use the Snoop tool to look at the tree and DataContext to see what's happening.
Going up a couple of levels in the tree, the DataContext will be a Xceed Group.
This group has a collection of items.
Your TestFieldGroupTemplate is applying to a Group.
So the main question is where is the group title coming from?
If you just want to change the group text, you can use a DataTemplate targeting Group.
(In the paid version TableflowView this will replace all their standard stuff).
Eg this passes the Group and DataGridControl to an IMultiValueConverter converter:
<DataTemplate DataType="{x:Type xcdg:Group}">
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource AnExampleConverter}">
<Binding Path="DataContext" RelativeSource="{RelativeSource TemplatedParent}"/>
<Binding RelativeSource="{RelativeSource AncestorType={x:Type xcdg:DataGridControl}}"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
I recently purchased Grialkit and was creating a simple walkthrough for an app that I'm developing.
I'm following the examples that are included in my grialkit.
I have a page, called WalkthroughPage. The XAML of this page looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WhoseKitchenApp.Views.Walkthroughs.WalkthroughPage"
xmlns:artina="clr-namespace:UXDivers.Artina.Shared;assembly=UXDivers.Artina.Shared"
xmlns:local="clr-namespace:WhoseKitchenApp;assembly=WhoseKitchenApp">
<!-- following line is line 9 -->
<local:Views.Walkthroughs.Templates.WalkthroughStepItemTemplate BackgroundColor="#FF6600" Header="Header text 1" Text="Welcome slide 1" IconColor="#5F7DD4" ButtonBackgroundColor="#5F7DD4" ButtonText="Next" />
<!-- following line is line 11 -->
<local:Views.Walkthroughs.Templates.WalkthroughStepItemTemplate BackgroundColor="#FF6600" Header="Header text 2" Text="Hello slide 2" IconColor="#7C4ECD" ButtonBackgroundColor="#7C4ECD" ButtonText="Next" />
<local:Views.Walkthroughs.Templates.WalkthroughStepItemTemplate BackgroundColor="#FF6600" Header="Header text 3" Text="Last slide, slide 3" IconColor="#E51E61" ButtonBackgroundColor="#E51E61" ButtonText="Finish" />
</CarouselPage>
I created an template called WalkthroughStepItemTemplate which I use to display information about the app.
When running my app, I get an XamlParseException:
Position 11:6. Type local:Views.Walkthroughs.Templates.WalkthroughStepItemTemplate not found in xmlns clr-namespace:WhoseKitchenApp;assembly=WhoseKitchenApp
In the code above, I placed a comment where that line 11 is. As you can see, the first time WalkthroughStepItemTemplate is called it looks just fine, but on the second try, it generates the exception.
I tried changing the clr-namespace to WhoseKitchenApp.Views.Walkthroughs.Templates, but I still have the same exception than. Also changing line 11 in the example to
<local:WalkthroughStepItemTemplate ...
has no effect.
Linker Behavior for both iOS and Android apps is set to Don't Link - Tip from the SO question
I'm wondering why the second (and third) time I get an XamlParseException.
I want to make a TextBlock visible only when a collection is empty. I have a ListView that is data-bound to the collection already and that's simple. I just want to display something else when the ListView is otherwise empty.
I wrote an IValueConverter that would take the collection, or count, or whatever I need, and return a Visibility appropriately. The XAML looks like this:
<TextBlock Visibility="{Binding Count, ElementName=ContactsList, Converter={StaticResource visibilityWhenEmpty}}"
Text="No contacts yet. Add one using the AppBar below." />
The trouble is that binding just the collection itself only calls my value converter once, when it's empty, and not again when the contents of the collection changes (kinda makes sense). And when, as shown above, I try binding against the collection's Count property, it doesn't call my value converter at all.
Any ideas?
I have faced the same issue. I applied a tricky solution. It might work for you as well. Taks a temporary combo box and bind the collection with that.
<ComboBox x:Name="TempComboBox"
ItemsSource="{Binding DataContext.ContactsList,
RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" >
<ComboBox.Template>
<ControlTemplate>
<!--Add file button..-->
<TextBlock Content="Your text..."
>
<TextBlock.Visibility>
<Binding Path="Items.Count"
RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType=ComboBox}"
Converter="{StaticResource visibilityWhenEmpty}">
</Binding>
</TextBlock.Visibility>
</TextBlock>
</ControlTemplate>
</ComboBox.Template>
</ComboBox>
You could use notifyPropertyChanged for Count, or implement using BindableBase.
when try a simple wcf service call at client, the string data member received at service side has its whitespaces at the beginning removed if we using binding as below.
binding:
<binding name="WSHttpBinding_CustomerService"
messageEncoding="Mtom" >
<security mode="None" />
</binding>
the question is: why is the front whitespace removed at service side when using this binding?
however,
1. if we use "Text" instead of "Mtom", no whitespace removed at service side.
2. if we remove
<security mode="None" />
and keep "Mtom", also no whitespace removed at service side.
client side ---
string customerName = " before and after ";
double totalAmount = customerAccountService.AddBalance(customerName , 100);
service side ---
the customerName becomes "before and after "
Microsoft has confirmed this as a bug:
http://connect.microsoft.com/wcf/feedback/details/619894/strings-stripped-of-leading-whitespace-when-using-mtom-message-encoding
What is the syntax for using XPath with Binding in XAML? Are there any MSDN pages which describe where to put the braces?
Visual Studio doesn't like the following:
<TextBlock Text="{Binding XPath=/One/Two[#id='0']/Three/#Four}" />
I want the Text of the TextBlock to be set to the value of the Four attribute.
Looking at the documentation, you should set the binding using nested syntax as follows:
<TextBlock>
<TextBlock.Text>
<Binding XPath="/One/Two[#id='0']/Three/#Four" />
</TextBlock.Text>
</TextBlock>